Mingli-Rui opened a new pull request, #38452:
URL: https://github.com/apache/spark/pull/38452

   ### What changes were proposed in this pull request?
   This PR changed to resolve the JDBC Relation schema with 
PreparedStatement.executeQuery() instead of PreparedStatement.getMetaData(). 
The main changes are:
   1. Add a new function: getQueryOutputSchema(...) to JdbcDialect. By default 
it will use getMetaData() to resolve schema.
   2. For 3 database dialect: H2Dialect, MsSqlServerDialect and MySqlDialect, 
override this function to use executeQuery() to resolve the schema because they 
doesn't support getMetaData() well.
   3. Add 2 utility functions to JdbcUtils for the 2 ways to resolving schema.
   
   ### Why are the changes needed?
   1. getMetaData() is better performance compared with executeQuery() because
      getMetaData() only needs to compile the Query, but executeQuery() needs 
to execute the query.
   2. Move the schema resolution to JdbcDialect, make it possible to resolve 
schema differently for each database.
       In the future, spark can support some non-SELECT query such as CALL 
PROC, etc.
   
   ### Does this PR introduce _any_ user-facing change?
   No
   
   ### How was this patch tested?
   Tested with existing 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.

To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to