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

from_json should accept an aggregate function as schema

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Minor
    • Resolution: Won't Fix
    • 2.3.1
    • None
    • SQL
    • None

    Description

      Currently, the from_json() function accepts only string literals as schema:

      JsonToStructs should be modified to accept results of aggregate functions like infer_schema (see SPARK-24642). It should be possible to write SQL like:

      select from_json(json_col, infer_schema(json_col)) from json_table
      

      Here is a test case with existing aggregate function - first():

      create temporary view schemas(schema) as select * from values
        ('struct<a:int>'),
        ('map<string,int>');
      
      select from_json('{"a":1}', first(schema)) from schemas;
      

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              maxgekk Max Gekk
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: