huaxingao commented on a change in pull request #34673:
URL: https://github.com/apache/spark/pull/34673#discussion_r759743604
##########
File path:
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/jdbc/JdbcUtils.scala
##########
@@ -1078,26 +1080,50 @@ object JdbcUtils extends Logging with SQLConfHelper {
*/
def checkIfIndexExists(
conn: Connection,
- indexName: String,
sql: String,
- indexColumnName: String,
options: JDBCOptions): Boolean = {
val statement = conn.createStatement
try {
statement.setQueryTimeout(options.queryTimeout)
val rs = statement.executeQuery(sql)
- while (rs.next()) {
- val retrievedIndexName = rs.getString(indexColumnName)
- if (conf.resolver(retrievedIndexName, indexName)) {
- return true
- }
- }
- false
+ rs.next
+ } catch {
+ case _: Exception =>
+ logWarning("Cannot retrieved index info.")
+ false
} finally {
statement.close()
}
}
+ /**
+ * Process index properties and return tuple of indexType and list of the
other index properties.
+ */
+ def processIndexProperties(
+ properties: util.Map[String, String],
+ options: JDBCOptions
+ ): (String, Array[String]) = {
+ val dialect = JdbcDialects.get(options.url)
+ var indexType = ""
+ var indexPropertyList: Array[String] = Array.empty
+
+ if (!properties.isEmpty) {
+ properties.asScala.foreach { case (k, v) =>
+ if (k.equals(SupportsIndex.PROP_TYPE)) {
+ if (v.equalsIgnoreCase("BTREE") || v.equalsIgnoreCase("HASH")) {
+ indexType = s"USING $v"
+ } else {
+ throw new UnsupportedOperationException(s"Index Type $v is not
supported." +
+ " The supported Index Types are: BTREE and HASH")
Review comment:
Seems PostgreSQL can support more index types
(https://www.postgresql.org/docs/9.5/sql-createindex.html).
--
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]