In JDBC for other databases, I found the following parameter explanation dbtable:
dbtable
The JDBC table to be read. Note that you can use everything that is valid in the FROM clause of the SQL query. For example, instead of a full table, you can also use a subquery in parentheses.
When I use the code:
CREATE TEMPORARY TABLE jdbcTable USING org.apache.spark.sql.jdbc OPTIONS ( url "jdbc:postgresql:dbserver", dbtable "mytable" )
everything works fine, but the following:
dbtable "SELECT * FROM mytable"
leads to an error:
What's wrong?
dbtable SELECT, , SQL-. , :
SELECT
CREATE TEMPORARY TABLE jdbcTable USING org.apache.spark.sql.jdbc OPTIONS ( url "jdbc:postgresql:dbserver", dbtable "(SELECT * FROM mytable) tmp" );
:
SELECT * FROM (SELECT * FROM mytable) tmp WHERE 1=0
Scala
val checkQuery = "(SELECT * FROM " + inputTableName + " ORDER BY " + columnName + " DESC LIMIT 1) AS timetable" val timeStampDf = spark.read.format("jdbc").option("url", url).option("dbtable", checkQuery).load()
.
Source: https://habr.com/ru/post/1673839/More articles:formatting a simple factorization algorithm - formattingThe main task of GCD - maximum TTL - iosNavigation and data transfer between pages Ionic 2 - jsonif else expression in reactjs map function - javascriptHow to use subquery for dbtable option in jdbc data source? - mysql.Net Standard or Portable Class Library moving forward? - .netGetting websocket 1006 error code when trying to connect to Actioncable server - ruby-on-railsYii2 Call api method from base controllers - restWhy does React require Babel and Webpack to work? - reactjsModeling Payment Data in Firebase 3 - nosqlAll Articles