ShowCreateTableCommand Logical Command¶
ShowCreateTableCommand is a logical command that <SHOW CREATE TABLE SQL statement (with a data source / non-Hive or a Hive table).
ShowCreateTableCommand is <SparkSqlAstBuilder is requested to parse <
[[output]] ShowCreateTableCommand uses a single createtab_stmt column (of type StringType) for the output schema.
import org.apache.spark.sql.SaveMode
spark.range(10e4.toLong)
.write
.bucketBy(4, "id")
.sortBy("id")
.mode(SaveMode.Overwrite)
.saveAsTable("bucketed_4_10e4")
scala> sql("SHOW CREATE TABLE bucketed_4_10e4").show(truncate = false)
+----------------------------------------------------------------------------------------------------------------------------------------------------+
|createtab_stmt |
+----------------------------------------------------------------------------------------------------------------------------------------------------+
|CREATE TABLE `bucketed_4_10e4` (`id` BIGINT)
USING parquet
OPTIONS (
`serialization.format` '1'
)
CLUSTERED BY (id)
SORTED BY (id)
INTO 4 BUCKETS
|
+----------------------------------------------------------------------------------------------------------------------------------------------------+
scala> sql("SHOW CREATE TABLE bucketed_4_10e4").as[String].collect.foreach(println)
CREATE TABLE `bucketed_4_10e4` (`id` BIGINT)
USING parquet
OPTIONS (
`serialization.format` '1'
)
CLUSTERED BY (id)
SORTED BY (id)
INTO 4 BUCKETS
[[table]] [[creating-instance]] ShowCreateTableCommand takes a single TableIdentifier when created.
=== [[run]] Executing Logical Command -- run Method
[source, scala]¶
run(sparkSession: SparkSession): Seq[Row]¶
NOTE: run is part of <
run requests the SparkSession for the <
run then requests the SessionCatalog to retrieve the table metadata from the external catalog (metastore).
run then <
In the end, run returns the CREATE TABLE statement in a single Row.
=== [[showHiveTableNonDataColumns]] showHiveTableNonDataColumns Internal Method
[source, scala]¶
showHiveTableNonDataColumns(metadata: CatalogTable, builder: StringBuilder): Unit¶
showHiveTableNonDataColumns...FIXME
NOTE: showHiveTableNonDataColumns is used exclusively when ShowCreateTableCommand logical command is requested to <
=== [[showCreateHiveTable]] showCreateHiveTable Internal Method
[source, scala]¶
showCreateHiveTable(metadata: CatalogTable): String¶
showCreateHiveTable...FIXME
NOTE: showCreateHiveTable is used exclusively when ShowCreateTableCommand logical command is executed (with a Hive <