<?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 SQL connector from databricks-sql-connector takes too much time to convert to pandas in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/sql-connector-from-databricks-sql-connector-takes-too-much-time/m-p/14171#M8709</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I am using querying my Delta Lake with SQL Connect and later want to explore the result in pandas.&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;with connection.cursor() as cursor:
        cur = cursor.execute("""
            SELECT DISTINCT sample_timestamp, value, name
            FROM default.raw_delta
            WHERE name in ( 'sensor-1', 'sensor-2, 'sensor-3','sensor-4')
             AND date &amp;gt;= 20200601
             AND date &amp;lt;= 20200731
            ORDER BY name, sample_timestamp
        """)
df = pd.DataFrame.from_records(cur.fetchall(), columns=['sample_timestamp', 'value', 'name'])
display(df)&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;While the query is really fast ~8s, the conversion to pandas takes almost 2 minutes.&lt;/P&gt;&lt;P&gt;I am running the code in local jupyter and also in databricks notebook, both with same performance. &lt;/P&gt;&lt;P&gt;What might cause the bad performance and is there a way to speed it up?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I also tried fetchall_arrow() but the pandas dimensions got mixed up (rows become columns).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks, &lt;/P&gt;&lt;P&gt;Leon    &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;   &lt;/P&gt;&lt;P&gt;&lt;/P&gt;</description>
    <pubDate>Sun, 10 Jul 2022 09:11:01 GMT</pubDate>
    <dc:creator>leon</dc:creator>
    <dc:date>2022-07-10T09:11:01Z</dc:date>
    <item>
      <title>SQL connector from databricks-sql-connector takes too much time to convert to pandas</title>
      <link>https://community.databricks.com/t5/data-engineering/sql-connector-from-databricks-sql-connector-takes-too-much-time/m-p/14171#M8709</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I am using querying my Delta Lake with SQL Connect and later want to explore the result in pandas.&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;with connection.cursor() as cursor:
        cur = cursor.execute("""
            SELECT DISTINCT sample_timestamp, value, name
            FROM default.raw_delta
            WHERE name in ( 'sensor-1', 'sensor-2, 'sensor-3','sensor-4')
             AND date &amp;gt;= 20200601
             AND date &amp;lt;= 20200731
            ORDER BY name, sample_timestamp
        """)
df = pd.DataFrame.from_records(cur.fetchall(), columns=['sample_timestamp', 'value', 'name'])
display(df)&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;While the query is really fast ~8s, the conversion to pandas takes almost 2 minutes.&lt;/P&gt;&lt;P&gt;I am running the code in local jupyter and also in databricks notebook, both with same performance. &lt;/P&gt;&lt;P&gt;What might cause the bad performance and is there a way to speed it up?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I also tried fetchall_arrow() but the pandas dimensions got mixed up (rows become columns).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks, &lt;/P&gt;&lt;P&gt;Leon    &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;   &lt;/P&gt;&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 10 Jul 2022 09:11:01 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/sql-connector-from-databricks-sql-connector-takes-too-much-time/m-p/14171#M8709</guid>
      <dc:creator>leon</dc:creator>
      <dc:date>2022-07-10T09:11:01Z</dc:date>
    </item>
    <item>
      <title>Re: SQL connector from databricks-sql-connector takes too much time to convert to pandas</title>
      <link>https://community.databricks.com/t5/data-engineering/sql-connector-from-databricks-sql-connector-takes-too-much-time/m-p/14173#M8711</link>
      <description>&lt;P&gt;thanks @Kaniz Fatma​&amp;nbsp; for the reply.&lt;/P&gt;&lt;P&gt;I am using sql.connector and do believe that the spark session is underline, is this config still relevant for sql.connector?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I overcome the fetchall_arrow() issue from my original question and do believe that I am using arrow implicitly now.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However, I don't see much improvements from fetchall and fetchall_arrow&lt;/P&gt;</description>
      <pubDate>Sun, 17 Jul 2022 08:28:59 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/sql-connector-from-databricks-sql-connector-takes-too-much-time/m-p/14173#M8711</guid>
      <dc:creator>leon</dc:creator>
      <dc:date>2022-07-17T08:28:59Z</dc:date>
    </item>
  </channel>
</rss>

