wayneguow commented on code in PR #49564:
URL: https://github.com/apache/spark/pull/49564#discussion_r1929522765


##########
sql/core/src/test/scala/org/apache/spark/sql/jdbc/JDBCSuite.scala:
##########
@@ -2206,4 +2206,44 @@ class JDBCSuite extends QueryTest with 
SharedSparkSession {
       JdbcUtils.schemaString(dialect, schema, caseSensitive = false, Some("b 
boolean"))
     assert(schemaStr === """"b" NUMBER(1) """)
   }
+
+  test("SPARK-50666: reading hint test") {
+    // JDBC url is a required option but is not used in this test.
+    val options = new JDBCOptions(Map("url" -> "jdbc:h2://host:port", 
"dbtable" -> "test",
+      "hint" -> "/*+ INDEX(test idx1) */"))
+    // hint supported
+    assert(
+      OracleDialect()
+        .getJdbcSQLQueryBuilder(options)
+        .withColumns(Array("a", "b"))
+        .build()
+        .trim() == "SELECT /*+ INDEX(test idx1) */ a,b FROM test")
+    assert(
+      MySQLDialect()
+        .getJdbcSQLQueryBuilder(options)
+        .withColumns(Array("a", "b"))
+        .build()
+        .trim() == "SELECT /*+ INDEX(test idx1) */ a,b FROM test")
+
+    // hint not supported with rewritten JdbcSQLQueryBuilder
+    assert(
+      DB2Dialect()
+        .getJdbcSQLQueryBuilder(options)
+        .withColumns(Array("a", "b"))
+        .build()
+        .trim() == "SELECT a,b FROM test")
+    assert(
+      MsSqlServerDialect()
+        .getJdbcSQLQueryBuilder(options)
+        .withColumns(Array("a", "b"))
+        .build()
+        .trim() == "SELECT  a,b FROM test")
+    // hint not supported with default JdbcSQLQueryBuilder
+    assert(
+      PostgresDialect()
+        .getJdbcSQLQueryBuilder(options)
+        .withColumns(Array("a", "b"))
+        .build()
+        .trim() == "SELECT a,b FROM test")

Review Comment:
   `PostgresDialect` does not rewrite `JdbcSQLQueryBuilder`, that's all. I 
think your suggestion is right and they can be merged together.



-- 
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]

Reply via email to