You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by "HyukjinKwon (via GitHub)" <gi...@apache.org> on 2024/01/23 02:11:07 UTC

[PR] [SPARK-46806][PYTHON] Improve error message for spark.table when argument type is wrong [spark]

HyukjinKwon opened a new pull request, #44846:
URL: https://github.com/apache/spark/pull/44846

   ### What changes were proposed in this pull request?
   
   This PR improves error message for spark.table when argument type is wrong
   
   ```python
   spark.table(None)
   ```
   
   **Before:**
   
   ```
   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)
   ```
   
   **After:**
   
   ```
   Traceback (most recent call last):
     File "<stdin>", line 1, in <module>
     File "/.../spark/python/pyspark/sql/session.py", line 1711, in table
       raise PySparkTypeError(
   pyspark.errors.exceptions.base.PySparkTypeError: [INVALID_TYPE] Argument `tableName` should not be a str.
   ```
   
   ### Why are the changes needed?
   
   For better error messages to the end users.
   
   
   ### Does this PR introduce _any_ user-facing change?
   
   Yes, it fixes the user-facing error messages.
   
   
   ### How was this patch tested?
   
   Unittest was added.
   
   ### Was this patch authored or co-authored using generative AI tooling?
   
   No.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-46806][PYTHON] Improve error message for spark.table when argument type is wrong [spark]

Posted by "HyukjinKwon (via GitHub)" <gi...@apache.org>.
HyukjinKwon commented on PR #44846:
URL: https://github.com/apache/spark/pull/44846#issuecomment-1905166238

   https://github.com/HyukjinKwon/spark/actions/runs/7620054063


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-46806][PYTHON] Improve error message for spark.table when argument type is wrong [spark]

Posted by "HyukjinKwon (via GitHub)" <gi...@apache.org>.
HyukjinKwon closed pull request #44846: [SPARK-46806][PYTHON] Improve error message for spark.table when argument type is wrong
URL: https://github.com/apache/spark/pull/44846


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-46806][PYTHON] Improve error message for spark.table when argument type is wrong [spark]

Posted by "HyukjinKwon (via GitHub)" <gi...@apache.org>.
HyukjinKwon commented on PR #44846:
URL: https://github.com/apache/spark/pull/44846#issuecomment-1905235852

   Merged to master.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org