Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support LATERAL VIEW json_tuple AS ... in Hive VIEW #7420

Merged
merged 2 commits into from
Mar 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -906,6 +906,7 @@ public int getMaxRecursionDepth()
}

@Config("max-recursion-depth")
@ConfigDescription("Maximum recursion depth for recursive common table expression")
findepi marked this conversation as resolved.
Show resolved Hide resolved
public FeaturesConfig setMaxRecursionDepth(int maxRecursionDepth)
{
this.maxRecursionDepth = maxRecursionDepth;
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
<dep.errorprone.version>2.5.1</dep.errorprone.version>
<dep.testcontainers.version>1.15.1</dep.testcontainers.version>
<dep.docker-java.version>3.2.7</dep.docker-java.version>
<dep.coral.version>1.0.33</dep.coral.version>
<dep.coral.version>1.0.37</dep.coral.version>
<dep.confluent.version>5.5.2</dep.confluent.version>

<!--
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,4 +118,22 @@ public void testLateralViewExplode()
row("nothing", null),
row("zero", null)));
}

@Test(groups = HIVE_VIEWS)
public void testLateralViewJsonTupleAs()
{
onTrino().executeQuery("DROP TABLE IF EXISTS test_json_tuple_table");
onTrino().executeQuery("" +
"CREATE TABLE test_json_tuple_table AS " +
"SELECT 3 id, CAST('{\"user_id\": 1000, \"first.name\": \"Mateusz\", \"Last Name\": \"Gajewski\", \".NET\": true, \"aNull\": null}' AS varchar) jsonstr");

onHive().executeQuery("DROP VIEW IF EXISTS test_json_tuple_view");
onHive().executeQuery("CREATE VIEW test_json_tuple_view AS " +
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good. Do you support the cN syntax alrady (without explicit column names)?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-> #7456

"SELECT `t`.`id`, `x`.`a`, `x`.`b`, `x`.`c`, `x`.`d`, `x`.`e`, `x`.`f` FROM test_json_tuple_table AS `t` " +
"LATERAL VIEW json_tuple(`t`.`jsonstr`, \"first.name\", \"Last Name\", '.NET', \"user_id\", \"aNull\", \"nonexistentField\") `x` AS `a`, `b`, `c`, `d`, `e`, `f`");

assertViewQuery(
"SELECT * FROM test_json_tuple_view",
queryAssert -> queryAssert.containsOnly(row(3, "Mateusz", "Gajewski", "true", "1000", null, null)));
}
}