maropu commented on a change in pull request #25287: 
[SPARK-28552][SQL]Identification of different dialects insensitive to case by 
JDBC URL prefix
URL: https://github.com/apache/spark/pull/25287#discussion_r340936584
 
 

 ##########
 File path: sql/core/src/test/scala/org/apache/spark/sql/jdbc/JDBCSuite.scala
 ##########
 @@ -1649,4 +1649,50 @@ class JDBCSuite extends QueryTest
       }
     }
   }
+
+  test("SPARK-28552: Check whether a dialect instance can be applied on the 
given jdbc url") {
+    var dialects = List[JdbcDialect]()
+
+    def registerDialect(dialect: JdbcDialect) : Unit = {
+      dialects = dialect :: dialects.filterNot(_ == dialect)
+    }
+
+    registerDialect(MySQLDialect)
+    registerDialect(PostgresDialect)
+    registerDialect(DB2Dialect)
+    registerDialect(MsSqlServerDialect)
+    registerDialect(DerbyDialect)
+    registerDialect(OracleDialect)
+    registerDialect(TeradataDialect)
+
+    def get(url: String): JdbcDialect = {
+      val matchingDialects = dialects.filter(_.canHandle(url))
+      matchingDialects.length match {
+        case 0 => NoopDialect
+        case 1 => matchingDialects.head
+        case _ => new AggregatedDialect(matchingDialects)
 
 Review comment:
   nit: we need the entries for `0` and `_`? I think the second one is only 
meaningful for this test?

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to