thomasrebele commented on code in PR #6727:
URL: https://github.com/apache/hive/pull/6727#discussion_r4667449237
##########
jdbc-handler/src/main/java/org/apache/hive/storage/jdbc/JdbcStorageHandler.java:
##########
@@ -107,10 +111,17 @@ public URI getURIForAuth(Table table) throws
URISyntaxException {
Map<String, String> tableProperties =
HiveCustomStorageHandlerUtils.getTableProperties(table);
DatabaseType dbType = DatabaseType.valueOf(
tableProperties.get(JdbcStorageConfig.DATABASE_TYPE.getPropertyName()));
- String host_url = DatabaseType.METASTORE == dbType ?
+ String hostUrl = DatabaseType.METASTORE == dbType ?
"jdbc:metastore://" : tableProperties.get(Constants.JDBC_URL);
- String table_name = tableProperties.get(Constants.JDBC_TABLE);
- return new URI(host_url+"/"+table_name);
+ String tableName = tableProperties.get(Constants.JDBC_TABLE);
+ // Tables defined through hive.sql.query (e.g. the sys and
information_schema tables) have no
+ // hive.sql.table, so their URI stays as before.
Review Comment:
[Resolved](https://github.com/orgs/community/discussions/19206), thanks!
##########
ql/src/test/org/apache/hadoop/hive/ql/exec/TestUtilities.java:
##########
@@ -902,4 +903,47 @@ private Set<String> getResultPathes(List<Path>
foundManifestFiles) {
}
return resultPathes;
}
+
+ @Test
+ public void testUnquoteJdbcIdentifierNullAndShortInputsUnchanged() {
+ assertNull(Utilities.unquoteJdbcIdentifier(null));
+ assertEquals("", Utilities.unquoteJdbcIdentifier(""));
+ // A single character cannot be a matched quote pair.
+ assertEquals("\"", Utilities.unquoteJdbcIdentifier("\""));
+ }
+
+ @Test
+ public void testUnquoteJdbcIdentifierUnquotedInputUnchanged() {
+ // Unquoted identifiers keep the current (case-insensitive) behaviour.
Review Comment:
[Resolved](https://github.com/orgs/community/discussions/19206), thanks!
##########
ql/src/test/org/apache/hadoop/hive/ql/exec/TestUtilities.java:
##########
@@ -902,4 +903,47 @@ private Set<String> getResultPathes(List<Path>
foundManifestFiles) {
}
return resultPathes;
}
+
+ @Test
+ public void testUnquoteJdbcIdentifierNullAndShortInputsUnchanged() {
+ assertNull(Utilities.unquoteJdbcIdentifier(null));
+ assertEquals("", Utilities.unquoteJdbcIdentifier(""));
+ // A single character cannot be a matched quote pair.
+ assertEquals("\"", Utilities.unquoteJdbcIdentifier("\""));
+ }
+
+ @Test
+ public void testUnquoteJdbcIdentifierUnquotedInputUnchanged() {
+ // Unquoted identifiers keep the current (case-insensitive) behaviour.
+ assertEquals("Country", Utilities.unquoteJdbcIdentifier("Country"));
+ assertEquals("country", Utilities.unquoteJdbcIdentifier("country"));
+ assertEquals("COUNTRY", Utilities.unquoteJdbcIdentifier("COUNTRY"));
+ }
+
+ @Test
+ public void testUnquoteJdbcIdentifierStripsSupportedQuotePairs() {
+ // ANSI / Oracle / Postgres double quotes.
+ assertEquals("Country", Utilities.unquoteJdbcIdentifier("\"Country\""));
+ // MySQL / MariaDB back-ticks.
+ assertEquals("Country", Utilities.unquoteJdbcIdentifier("`Country`"));
+ // SQL Server brackets.
+ assertEquals("Country", Utilities.unquoteJdbcIdentifier("[Country]"));
+ // Schema-style identifiers with mixed case are preserved after unquoting.
+ assertEquals("WorldData",
Utilities.unquoteJdbcIdentifier("\"WorldData\""));
Review Comment:
I meant, if Hive removes the outer quote pair from `"[Country]"`, and the
database removes the inner quote pair, then there would be a collision. If I
recall correctly, the DBMS that I checked only accepted one kind of quotes, so
this problem should not occur.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]