Skip to content

Support json_tuple in SELECT clause in Hive #483

@Light-Towers

Description

@Light-Towers

Describe the bug

  • No dialect parameters are normal. Use Hive dialect will error.

SQL
Paste the SQL text here. For example:

INSERT OVERWRITE table dw.dim_dict partition (dt)
select get_json_object(replace(t.id, '$', ''), '$.oid') as id,
       t.industry_code,
       t.industry,
       t.sec_industry_code,
       t.sec_industry,
       t.type,
       t.version,
       current_date                                     as dt
from (select json_tuple(line, '_id', 'industryCode', 'industry', 'secIndustryCode', 'secIndustry', 'type', 'version')
                 as (id, industry_code, industry, sec_industry_code, sec_industry, type, version)
      from default.tmp_json) t;

To Reproduce

# -*- coding: utf-8 -*-
from sqllineage.runner import LineageRunner

def test_create_as():
    sql = """
INSERT OVERWRITE table dw.dim_dict partition (dt)
select get_json_object(replace(t.id, '$', ''), '$.oid') as id,
       t.industry_code,
       t.industry,
       t.sec_industry_code,
       t.sec_industry,
       t.type,
       t.version,
       current_date                                     as dt
from (select json_tuple(line, '_id', 'industryCode', 'industry', 'secIndustryCode', 'secIndustry', 'type', 'version')
                 as (id, industry_code, industry, sec_industry_code, sec_industry, type, version)
      from default.tmp_json) t;
    """
    # result = LineageRunner(sql)
    result = LineageRunner(sql, 'hive')
    result.print_column_lineage()
    print(result.source_tables)
    print(result.target_tables)

if __name__ == "__main__":
    test_create_as()
Line 11, Position 18: Found unparsable section: 'as (id, industry_code, industry, sec_ind...'

Python version (available via python --version)

  • 3.10.11

SQLLineage version (available via sqllineage --version):

  • 1.4.8

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestparsersomething that requires a strict/validating SQL parser

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions