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
[FLINK-13814][hive] HiveTableSink should strip quotes from partition … #9502
Conversation
Thanks a lot for your contribution to the Apache Flink project. I'm the @flinkbot. I help the community Automated ChecksLast check on commit 6901271 (Fri Aug 30 22:22:15 UTC 2019) Warnings:
Mention the bot in a comment to re-run the automated checks. Review Progress
Please see the Pull Request Review Guide for a full explanation of the review process. The Bot is tracking the review progress through labels. Labels are applied according to the order of the review items. For consensus, approval by a Flink committer of PMC member is required Bot commandsThe @flinkbot bot supports the following commands:
|
@@ -170,7 +171,7 @@ public void setStaticPartition(Map<String, String> partitionSpec) { | |||
staticPartitionSpec = new LinkedHashMap<>(); | |||
for (String partitionCol : getPartitionFieldNames()) { | |||
if (partitionSpec.containsKey(partitionCol)) { | |||
staticPartitionSpec.put(partitionCol, partitionSpec.get(partitionCol)); | |||
staticPartitionSpec.put(partitionCol, PlanUtils.stripQuotes(partitionSpec.get(partitionCol))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just curious, partitionSpec is a map of strings, and the value should probably have been unquoted before getting here. I'm wondering if the fix should be at a lower level than here. Otherwise, similar fix will be needed wherever such partition spec is used.
2227892
to
5ad14b3
Compare
PR updated to get unquoted partition values in |
@@ -75,7 +77,8 @@ public SqlNodeList getStaticPartitions() { | |||
} | |||
for (SqlNode node : this.staticPartitions.getList()) { | |||
SqlProperty sqlProperty = (SqlProperty) node; | |||
String value = SqlLiteral.value(sqlProperty.getValue()).toString(); | |||
Comparable comparable = SqlLiteral.value(sqlProperty.getValue()); | |||
String value = comparable instanceof NlsString ? ((NlsString) comparable).getValue() : comparable.toString(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm ok with the RichSqlInsert
change.
hiveShell.insertInto("db1", "src").addRow(1).addRow(2).commit(); | ||
hiveShell.execute("create table db1.dest (x int) partitioned by (p1 string, p2 double)"); | ||
TableEnvironment tableEnv = getTableEnvWithHiveCatalog(); | ||
tableEnv.sqlUpdate("insert into db1.dest partition (p1='1''1', p2=1.1) select x from db1.src"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm wondering what this means and why a user might do this: p1='1''1'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree, a little confusing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree this may not be common use case, but theoretically a string partition column can take any valid values including those with single quotes. And Hive also supports this.
5ad14b3
to
2215b05
Compare
@xuefuz Do you have any further comments? |
No. It looks good to me. Thanks. |
LGTM, merging |
The following test is failing on my machine:
|
2215b05
to
6901271
Compare
@bowenli86 I can't reproduce the error you mentioned. Rebase to trigger travis again. |
Seems the latest Travis build passed. |
…values
What is the purpose of the change
Strip quotes from partition value in order to get proper string values.
Brief change log
TableEnvHiveConnectorTest
since the planner has now supportedPartitionableTableSink
Verifying this change
Added test case
Does this pull request potentially affect one of the following parts:
@Public(Evolving)
: noDocumentation