-
Notifications
You must be signed in to change notification settings - Fork 13k
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-22207][connectors/hive]Hive Catalog retrieve Flink Properties … #15564
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 8eaeab3 (Fri May 28 09:06:10 UTC 2021) 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:
|
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.
Thanks for the fix, could you add a test case?
hello , I test the bug in sql-client After this fix is works fine |
@hameizi I'm pretty sure you fixed the bug and the change also LGTM. But by adding a test case can help the project won't introduce the same bug by accident in the future. |
@KurtYoung I add test case in new commit. Please review. Thanks |
@@ -78,4 +80,17 @@ public void testCreateHiveTable() { | |||
prop.keySet().stream() | |||
.noneMatch(k -> k.startsWith(CatalogPropertiesUtil.FLINK_PROPERTY_PREFIX))); | |||
} | |||
|
|||
@Test | |||
public void testRetrieveFlinkProperties() throws ClassNotFoundException, NoSuchMethodException, InvocationTargetException, IllegalAccessException { |
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.
Can you choose another way to test this? Relying on private method is not a good practice.
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.
@KurtYoung Thanks for you review, i change the test case, please review it.
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.
Please also fix the format error
Map<String, String> properties = new HashMap<>(new FileSystem().path("/test_path").toProperties()); | ||
|
||
properties.put(CatalogPropertiesUtil.IS_GENERIC, String.valueOf(true)); | ||
properties.put("url", "jdbc:clickhouse://host:port/default"); |
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.
set this property to a different value and also verify you can get this property correctly?
CatalogTable source = new CatalogTableImpl(schema, properties, null); | ||
|
||
hiveCatalog.createTable( | ||
hiveObjectPath, source, false); |
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.
unnecessary wrap here
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.
Sorry, i can't understand this
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.
Do you mean like this?
hiveCatalog.createTable(
hiveObjectPath, new CatalogTableImpl(schema, properties, null), false);
@@ -78,4 +99,23 @@ public void testCreateHiveTable() { | |||
prop.keySet().stream() | |||
.noneMatch(k -> k.startsWith(CatalogPropertiesUtil.FLINK_PROPERTY_PREFIX))); | |||
} | |||
|
|||
@Test | |||
public void testRetrieveFlinkProperties() throws TableAlreadyExistException, DatabaseNotExistException, TableNotExistException { |
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.
throws Exception is enough
@KurtYoung Hello, i push a new commit, thanks for your review. |
hiveObjectPath, new CatalogTableImpl(schema, properties, null), false); | ||
|
||
CatalogBaseTable hiveTable = hiveCatalog.getTable(hiveObjectPath); | ||
assertEquals(hiveTable.getOptions().get("flink.url"), "jdbc:clickhouse://host:port/testUrl2"); |
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.
check we can get "url" correctly
[ERROR] Failed to execute goal com.diffplug.spotless:spotless-maven-plugin:2.4.2:check (spotless-check) on project flink-connector-hive_2.11: The following files had format violations: |
@KurtYoung I fix in the new commit, please review thanks |
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.
LGTM
@hameizi If you want to fix this in 1.12.3, you can also create a PR against release-1.12 branch. |
ok, thanks |
What is the purpose of the change
Fix hive catalog handle propertie error "java.lang.IllegalStateException: Duplicate key". As said in FLINK-22207 like below.
If we use hive catalog and set flink propertie eg."url",and then when we add the other propertie like start with string "flink." like "flink.url" will show we the error "java.lang.IllegalStateException: Duplicate key" , and what's worse is because of this error we can`t drop or alter this tabel more.
I found in this method , "org.apache.flink.table.catalog.hive.HiveCatalog.retrieveFlinkProperties", replace all "flink." of propertie. So , the propertie of HiveCatalog "flink.url" and "flink.flink.url" both result to "url".
Brief change log
Hive Catalog retrieve Flink Properties error
Verifying this change
Manually verified.
Does this pull request potentially affect one of the following parts:
Dependencies (does it add or upgrade a dependency): (yes / no)
The public API, i.e., is any changed class annotated with @public(Evolving): (yes / no)
The serializers: (yes / no / don't know)
The runtime per-record code paths (performance sensitive): (yes / no / don't know)
Anything that affects deployment or recovery: JobManager (and its components), Checkpointing, Kubernetes/Yarn/Mesos, ZooKeeper: (yes / no / don't know)
The S3 file system connector: (yes / no / don't know)
Documentation
Does this pull request introduce a new feature? (yes / no)
If yes, how is the feature documented? (not applicable / docs / JavaDocs / not documented)