<?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 Re: COPY INTO command can not recognise MAP type value from JSON file in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/copy-into-command-can-not-recognise-map-type-value-from-json/m-p/22468#M15391</link>
    <description>&lt;P&gt;@Alexey Murashev​&amp;nbsp;Could you please paste create table (DDL) statement for the hive table? &lt;/P&gt;</description>
    <pubDate>Tue, 02 Aug 2022 05:45:55 GMT</pubDate>
    <dc:creator>User16763506477</dc:creator>
    <dc:date>2022-08-02T05:45:55Z</dc:date>
    <item>
      <title>COPY INTO command can not recognise MAP type value from JSON file</title>
      <link>https://community.databricks.com/t5/data-engineering/copy-into-command-can-not-recognise-map-type-value-from-json/m-p/22462#M15385</link>
      <description>&lt;P&gt;I have a delta table in Databricks with single column of type map&amp;lt;string, string&amp;gt; and I have a data file in JSON format created by Hive 3 for the table with thecolumn of same type. And I want to load data from file to Databricks's table using COPY INTO command.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I tried this command &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;COPY INTO db1.table1 FROM (SELECT CAST(map1 AS map&amp;lt;string,string&amp;gt;) AS map1 FROM '/') FILEFORMAT = JSON FILES = ('/mnt/external/repl_test/db1/table1/000000_0')  COPY_OPTIONS ('force'='true');&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;But got an error&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;Error in SQL statement: AnalysisException: cannot resolve '`map1`' due to data type mismatch: cannot cast struct&amp;lt;key:string&amp;gt; to map&amp;lt;string,string&amp;gt;; line 1 pos 34;
'Project [cast(map1#6876 as map&amp;lt;string,string&amp;gt;) AS map1#6856]
+- Relation[map1#6876] json&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;JSON file has the following content &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;{"map1":{"key":"value"}}&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;it was generated while inserting data to Hive3 table stored with SerDe org.apache.hadoop.hive.serde2.JsonSerDe.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is there a proper way to load json file with maps to the delta table? &lt;/P&gt;&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 21 Apr 2022 09:27:24 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/copy-into-command-can-not-recognise-map-type-value-from-json/m-p/22462#M15385</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-04-21T09:27:24Z</dc:date>
    </item>
    <item>
      <title>Re: COPY INTO command can not recognise MAP type value from JSON file</title>
      <link>https://community.databricks.com/t5/data-engineering/copy-into-command-can-not-recognise-map-type-value-from-json/m-p/22463#M15386</link>
      <description>&lt;P&gt;@Alexey Murashev​&amp;nbsp;, That struct&amp;lt;key: string&amp;gt; is just a nested column. It is nothing in common with the map, so you can not cast it. Look for the below examples with {"map1":{"key":"value"}}:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="image.png"&gt;&lt;img src="https://community.databricks.com/t5/image/serverpage/image-id/1935i0B8E09E1A070B0F6/image-size/large?v=v2&amp;amp;px=999" role="button" title="image.png" alt="image.png" /&gt;&lt;/span&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 21 Apr 2022 10:12:50 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/copy-into-command-can-not-recognise-map-type-value-from-json/m-p/22463#M15386</guid>
      <dc:creator>Hubert-Dudek</dc:creator>
      <dc:date>2022-04-21T10:12:50Z</dc:date>
    </item>
    <item>
      <title>Re: COPY INTO command can not recognise MAP type value from JSON file</title>
      <link>https://community.databricks.com/t5/data-engineering/copy-into-command-can-not-recognise-map-type-value-from-json/m-p/22464#M15387</link>
      <description>&lt;P&gt;Thanks for the answer! &lt;/P&gt;&lt;P&gt;In my case I just want to migrate data from Hive table to Databricks delta table. Both tables have the same schema with column of type map&amp;lt;string,string&amp;gt;. So I just not understand is there straight and proper way to migrate data using COPY INTO command in case of source table stores data in JSON format? &lt;/P&gt;</description>
      <pubDate>Thu, 21 Apr 2022 10:42:19 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/copy-into-command-can-not-recognise-map-type-value-from-json/m-p/22464#M15387</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-04-21T10:42:19Z</dc:date>
    </item>
    <item>
      <title>Re: COPY INTO command can not recognise MAP type value from JSON file</title>
      <link>https://community.databricks.com/t5/data-engineering/copy-into-command-can-not-recognise-map-type-value-from-json/m-p/22465#M15388</link>
      <description>&lt;P&gt;@Alexey Murashev​&amp;nbsp; COPY INTO is ok just you need to make some transformation of struct&amp;lt;key:string&amp;gt; as cast will not work in such a case.&lt;/P&gt;</description>
      <pubDate>Thu, 21 Apr 2022 10:51:39 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/copy-into-command-can-not-recognise-map-type-value-from-json/m-p/22465#M15388</guid>
      <dc:creator>Hubert-Dudek</dc:creator>
      <dc:date>2022-04-21T10:51:39Z</dc:date>
    </item>
    <item>
      <title>Re: COPY INTO command can not recognise MAP type value from JSON file</title>
      <link>https://community.databricks.com/t5/data-engineering/copy-into-command-can-not-recognise-map-type-value-from-json/m-p/22467#M15390</link>
      <description>&lt;P&gt;Hi @Kaniz Fatma​&amp;nbsp;, actually I didn't find the solution for this moment. I also limited to use only SQL in my query, so I can't use Scala or Python. &lt;/P&gt;</description>
      <pubDate>Mon, 25 Apr 2022 08:16:00 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/copy-into-command-can-not-recognise-map-type-value-from-json/m-p/22467#M15390</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-04-25T08:16:00Z</dc:date>
    </item>
    <item>
      <title>Re: COPY INTO command can not recognise MAP type value from JSON file</title>
      <link>https://community.databricks.com/t5/data-engineering/copy-into-command-can-not-recognise-map-type-value-from-json/m-p/22468#M15391</link>
      <description>&lt;P&gt;@Alexey Murashev​&amp;nbsp;Could you please paste create table (DDL) statement for the hive table? &lt;/P&gt;</description>
      <pubDate>Tue, 02 Aug 2022 05:45:55 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/copy-into-command-can-not-recognise-map-type-value-from-json/m-p/22468#M15391</guid>
      <dc:creator>User16763506477</dc:creator>
      <dc:date>2022-08-02T05:45:55Z</dc:date>
    </item>
    <item>
      <title>Re: COPY INTO command can not recognise MAP type value from JSON file</title>
      <link>https://community.databricks.com/t5/data-engineering/copy-into-command-can-not-recognise-map-type-value-from-json/m-p/22469#M15392</link>
      <description>&lt;P&gt;Hi Alexey,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Just a friendly follow-up. Did any of the responses help you to resolve your question? if it did, please mark it as best. Otherwise, please let us know if you still need help.&lt;/P&gt;</description>
      <pubDate>Mon, 29 Aug 2022 22:57:22 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/copy-into-command-can-not-recognise-map-type-value-from-json/m-p/22469#M15392</guid>
      <dc:creator>jose_gonzalez</dc:creator>
      <dc:date>2022-08-29T22:57:22Z</dc:date>
    </item>
    <item>
      <title>Re: COPY INTO command can not recognise MAP type value from JSON file</title>
      <link>https://community.databricks.com/t5/data-engineering/copy-into-command-can-not-recognise-map-type-value-from-json/m-p/133804#M49928</link>
      <description>&lt;P&gt;Use&lt;/P&gt;&lt;PRE&gt;from_json(to_json({struct column}),{your schema definition})&lt;/PRE&gt;&lt;P&gt;For example&lt;/P&gt;&lt;PRE&gt;COPY INTO {table} FROM (select from_json(to_json()), 'MAP&amp;lt;STRING, STRING&amp;gt;' FROM {path}) ...&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 05 Oct 2025 08:50:50 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/copy-into-command-can-not-recognise-map-type-value-from-json/m-p/133804#M49928</guid>
      <dc:creator>Y-I</dc:creator>
      <dc:date>2025-10-05T08:50:50Z</dc:date>
    </item>
  </channel>
</rss>

