Description:
Query a Spark database.
Syntax:
spark_query(con,sql/tableName)
Note:
External library function (See External Library Guide).
The function queries Spark table data using a SQL statement or file query methods, and returns result data.
Parameter:
con |
Database connection string, which can be a normal Spark connection, a Spark connection using Hudi/Iceberg format, or a Spark connection using Hudi/Iceberg format used with S3. |
sql |
A SQL statement, like select * from table. |
tableName |
A table name (query the table data using file query methods), which forms a url along with parameter warehouse in configuration file .properties, such as hdfs://localhost:9000/user/hive/warehouse/tableName, which shows the location of the table in HDFS. |
Option:
@c |
Return a cursor. |
@d |
Do not display the automatically generated field for a Hudi table; only invalid for Hudi tables. |
Return value:
Table sequence
Example:
|
A |
|
1 |
=spark_open("spark.properties") |
Connect to a Spark database. |
2 |
|
Query data using a SQL statement. |
3 |
|
|
4 |
|
Connect to a Spark database using Hudi format. |
5 |
|
Do not display the automatically generated field for the Hudi table in the returned result set. |
6 |
|
|
7 |
|
Connect to a Spark database using Iceberg format. |
8 |
|
Query data using a file query method, during which the table name forms a url along with parameter warehouse in configuration file , such as hdfs://localhost:9000/user/hive/warehouse/icetest1. |
9 |
|
|
10 |
|
Connect to a Spark database using Hudi format used with S3. |
11 |
|
Query data and return a cursor. |
12 |
|
|
13 |
|
Connect to a Spark database using Iceberg format used with S3. |
14 |
|
Query data using a SQL statement. |
15 |
|
|