<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic SparkSession conf : strange bug when injecting property &amp;quot;hourl&amp;quot; in SQL query in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/sparksession-conf-strange-bug-when-injecting-property-quot-hourl/m-p/46815#M28134</link>
    <description>&lt;P&gt;Assuming you have a catalog "my_catalog" and a schema "my_schema", the following code is not working :&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;full_table_location = "`my_catalog`.`my_schema`.`my_table_hourl`"
spark.conf.set("fullTableName", full_table_location)
spark.sql("""SELECT * FROM ${fullTableName} LIMIT 1""")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;... not because table is not found but because table name contains "hourl" string. It generates the following ParseException because my_catalog.my_schema.my_table_hourl has been obfuscated with&amp;nbsp;&lt;SPAN&gt;*********(redacted).&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;ParseException                            Traceback (most recent call last)
File &amp;lt;command-1602645165993644&amp;gt;, line 1
----&amp;gt; 1 spark.sql("""SELECT * FROM ${a} LIMIT 1""")

File /databricks/spark/python/pyspark/instrumentation_utils.py:48, in _wrap_function.&amp;lt;locals&amp;gt;.wrapper(*args, **kwargs)
     46 start = time.perf_counter()
     47 try:
---&amp;gt; 48     res = func(*args, **kwargs)
     49     logger.log_success(
     50         module_name, class_name, function_name, time.perf_counter() - start, signature
     51     )
     52     return res

File /databricks/spark/python/pyspark/sql/session.py:1602, in SparkSession.sql(self, sqlQuery, args, **kwargs)
   1598         assert self._jvm is not None
   1599         litArgs = self._jvm.PythonUtils.toArray(
   1600             [_to_java_column(lit(v)) for v in (args or [])]
   1601         )
-&amp;gt; 1602     return DataFrame(self._jsparkSession.sql(sqlQuery, litArgs), self)
   1603 finally:
   1604     if len(kwargs) &amp;gt; 0:

File /databricks/spark/python/lib/py4j-0.10.9.7-src.zip/py4j/java_gateway.py:1322, in JavaMember.__call__(self, *args)
   1316 command = proto.CALL_COMMAND_NAME +\
   1317     self.command_header +\
   1318     args_command +\
   1319     proto.END_COMMAND_PART
   1321 answer = self.gateway_client.send_command(command)
-&amp;gt; 1322 return_value = get_return_value(
   1323     answer, self.gateway_client, self.target_id, self.name)
   1325 for temp_arg in temp_args:
   1326     if hasattr(temp_arg, "_detach"):

File /databricks/spark/python/pyspark/errors/exceptions/captured.py:194, in capture_sql_exception.&amp;lt;locals&amp;gt;.deco(*a, **kw)
    190 converted = convert_exception(e.java_exception)
    191 if not isinstance(converted, UnknownException):
    192     # Hide where the exception came from that shows a non-Pythonic
    193     # JVM exception message.
--&amp;gt; 194     raise converted from None
    195 else:
    196     raise

ParseException: 
[PARSE_SYNTAX_ERROR] Syntax error at or near '*'.(line 1, pos 14)

== SQL ==
SELECT * FROM *********(redacted) LIMIT 1
--------------^^^&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;Since it works properly with anything but "hourl" substring, any idea of what's going wrong here ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 29 Sep 2023 14:27:12 GMT</pubDate>
    <dc:creator>sfalquier</dc:creator>
    <dc:date>2023-09-29T14:27:12Z</dc:date>
    <item>
      <title>SparkSession conf : strange bug when injecting property "hourl" in SQL query</title>
      <link>https://community.databricks.com/t5/data-engineering/sparksession-conf-strange-bug-when-injecting-property-quot-hourl/m-p/46815#M28134</link>
      <description>&lt;P&gt;Assuming you have a catalog "my_catalog" and a schema "my_schema", the following code is not working :&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;full_table_location = "`my_catalog`.`my_schema`.`my_table_hourl`"
spark.conf.set("fullTableName", full_table_location)
spark.sql("""SELECT * FROM ${fullTableName} LIMIT 1""")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;... not because table is not found but because table name contains "hourl" string. It generates the following ParseException because my_catalog.my_schema.my_table_hourl has been obfuscated with&amp;nbsp;&lt;SPAN&gt;*********(redacted).&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;ParseException                            Traceback (most recent call last)
File &amp;lt;command-1602645165993644&amp;gt;, line 1
----&amp;gt; 1 spark.sql("""SELECT * FROM ${a} LIMIT 1""")

File /databricks/spark/python/pyspark/instrumentation_utils.py:48, in _wrap_function.&amp;lt;locals&amp;gt;.wrapper(*args, **kwargs)
     46 start = time.perf_counter()
     47 try:
---&amp;gt; 48     res = func(*args, **kwargs)
     49     logger.log_success(
     50         module_name, class_name, function_name, time.perf_counter() - start, signature
     51     )
     52     return res

File /databricks/spark/python/pyspark/sql/session.py:1602, in SparkSession.sql(self, sqlQuery, args, **kwargs)
   1598         assert self._jvm is not None
   1599         litArgs = self._jvm.PythonUtils.toArray(
   1600             [_to_java_column(lit(v)) for v in (args or [])]
   1601         )
-&amp;gt; 1602     return DataFrame(self._jsparkSession.sql(sqlQuery, litArgs), self)
   1603 finally:
   1604     if len(kwargs) &amp;gt; 0:

File /databricks/spark/python/lib/py4j-0.10.9.7-src.zip/py4j/java_gateway.py:1322, in JavaMember.__call__(self, *args)
   1316 command = proto.CALL_COMMAND_NAME +\
   1317     self.command_header +\
   1318     args_command +\
   1319     proto.END_COMMAND_PART
   1321 answer = self.gateway_client.send_command(command)
-&amp;gt; 1322 return_value = get_return_value(
   1323     answer, self.gateway_client, self.target_id, self.name)
   1325 for temp_arg in temp_args:
   1326     if hasattr(temp_arg, "_detach"):

File /databricks/spark/python/pyspark/errors/exceptions/captured.py:194, in capture_sql_exception.&amp;lt;locals&amp;gt;.deco(*a, **kw)
    190 converted = convert_exception(e.java_exception)
    191 if not isinstance(converted, UnknownException):
    192     # Hide where the exception came from that shows a non-Pythonic
    193     # JVM exception message.
--&amp;gt; 194     raise converted from None
    195 else:
    196     raise

ParseException: 
[PARSE_SYNTAX_ERROR] Syntax error at or near '*'.(line 1, pos 14)

== SQL ==
SELECT * FROM *********(redacted) LIMIT 1
--------------^^^&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;Since it works properly with anything but "hourl" substring, any idea of what's going wrong here ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 29 Sep 2023 14:27:12 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/sparksession-conf-strange-bug-when-injecting-property-quot-hourl/m-p/46815#M28134</guid>
      <dc:creator>sfalquier</dc:creator>
      <dc:date>2023-09-29T14:27:12Z</dc:date>
    </item>
  </channel>
</rss>

