Github user rxin commented on a diff in the pull request:
https://github.com/apache/spark/pull/8676#discussion_r39230872
--- Diff:
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/jdbc/JdbcUtils.scala
---
@@ -42,10 +42,13 @@ object JdbcUtils extends Logging {
/**
* Returns true if the table already exists in the JDBC database.
*/
- def tableExists(conn: Connection, table: String): Boolean = {
+ def tableExists(conn: Connection, url: String, table: String): Boolean =
{
+ val dialect = JdbcDialects.get(url)
+
// Somewhat hacky, but there isn't a good way to identify whether a
table exists for all
- // SQL database systems, considering "table" could also include the
database name.
- Try(conn.prepareStatement(s"SELECT 1 FROM $table LIMIT
1").executeQuery().next()).isSuccess
+ // SQL database systems using JDBC meta data calls, considering
"table" could also include
+ // the database name. Query used to find table exists can be overriden
by the dialects.
+
Try(conn.prepareStatement(dialect.getTableExistsQuery(table)).executeQuery().next()).isSuccess
--- End diff --
will next still return success if the query is where 1 = 0? there is no
result isn't there?
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]