Skip to content

Commit

Permalink
Use dialect's table-exists query rather than hard-coded WHERE 1=0 query
Browse files Browse the repository at this point in the history
  • Loading branch information
srowen committed Sep 22, 2016
1 parent 25a020b commit 27fe87d
Showing 1 changed file with 2 additions and 4 deletions.
Expand Up @@ -58,11 +58,11 @@ object JDBCRDD extends Logging {
val dialect = JdbcDialects.get(url)
val conn: Connection = JdbcUtils.createConnectionFactory(url, properties)()
try {
val statement = conn.prepareStatement(s"SELECT * FROM $table WHERE 1=0")
val statement = conn.prepareStatement(dialect.getTableExistsQuery(table))
try {
val rs = statement.executeQuery()
try {
return JdbcUtils.getSchema(rs, dialect)
JdbcUtils.getSchema(rs, dialect)
} finally {
rs.close()
}
Expand All @@ -72,8 +72,6 @@ object JDBCRDD extends Logging {
} finally {
conn.close()
}

throw new RuntimeException("This line is unreachable.")
}

/**
Expand Down

0 comments on commit 27fe87d

Please sign in to comment.