Uploaded image for project: 'Spark'
  1. Spark
  2. SPARK-46806

Improve error message for spark.table when argument type is wrong

    XMLWordPrintableJSON

Details

    Description

      >>> spark.table(None)
      Traceback (most recent call last):
        File "<stdin>", line 1, in <module>
        File "/.../spark/python/pyspark/sql/session.py", line 1710, in table
          return DataFrame(self._jsparkSession.table(tableName), self)
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/.../spark/python/lib/py4j-0.10.9.7-src.zip/py4j/java_gateway.py", line 1322, in __call__
        File "/.../spark/python/pyspark/errors/exceptions/captured.py", line 215, in deco
          return f(*a, **kw)
                 ^^^^^^^^^^^
        File "/.../spark/python/lib/py4j-0.10.9.7-src.zip/py4j/protocol.py", line 326, in get_return_value
      py4j.protocol.Py4JJavaError: An error occurred while calling o27.table.
      : java.lang.NullPointerException: Cannot invoke "String.length()" because "s" is null
      	at org.antlr.v4.runtime.CharStreams.fromString(CharStreams.java:222)
      	at org.antlr.v4.runtime.CharStreams.fromString(CharStreams.java:212)
      	at org.apache.spark.sql.catalyst.parser.AbstractParser.parse(parsers.scala:58)
      	at org.apache.spark.sql.execution.SparkSqlParser.parse(SparkSqlParser.scala:55)
      	at org.apache.spark.sql.catalyst.parser.AbstractSqlParser.parseMultipartIdentifier(AbstractSqlParser.scala:54)
      	at org.apache.spark.sql.DataFrameReader.table(DataFrameReader.scala:681)
      	at org.apache.spark.sql.SparkSession.table(SparkSession.scala:619)
      	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
      	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.base/java.lang.reflect.Method.invoke(Method.java:568)
      	at py4j.reflection.MethodInvoker.invoke(MethodInvoker.java:244)
      	at py4j.reflection.ReflectionEngine.invoke(ReflectionEngine.java:374)
      	at py4j.Gateway.invoke(Gateway.java:282)
      

      Attachments

        Issue Links

          Activity

            People

              gurwls223 Hyukjin Kwon
              gurwls223 Hyukjin Kwon
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: