CREATE TABLE
Function
CREATE TABLE is specific to Aura. It is used to create a table with a specified name on LakeFormation.
For details about expression-partitioned tables, see Expression Partitioning.
Precautions
- Columns appearing in PARTITION BY must not be described among the regular columns of the table. Partition columns are always positioned after the regular columns.
- PARTITION BY supports a maximum of four partition keys.
- CLUSTERED BY is applicable to ORC and Parquet file formats.
- PARTITION BY supports ORC, Parquet, Hudi, and Iceberg file formats.
- ctid and xc_node_id cannot be used as column names.
- For details about the main constraints on the currently implemented expression partitioning, see Notes and Constraints.
Syntax
1 2 3 4 5 6 7 8 9 | CREATE [ EXTERNAL ] TABLE [ IF NOT EXISTS ] [schema_name.]table_name [ ( col_name col_type [ COMMENT col_comment ] [, ... ] ) ] [ COMMENT table_comment ] [ PARTITION BY ( col_name col_type COMMENT col_comment | year(col_name) | month(col_name) | day(col_name) | hour(col_name)| truncate(width, col_name) | bucket(bucket_num, col_name)[, ... ] ) ] [ CLUSTERED BY (col_name [,...]) INTO ( bucket_num ) BUCKETS ] [ TABLEPROPERTIES ( option_key = option_value [, ... ] ) ] [ STORE AS table_format ] [ LOCATION table_path ] AS select_stmt; |
Parameter Description
- EXTERNAL
Specifying this keyword creates an EXTERNAL table. Omitting it defaults to creating a MANAGED table, where files, metadata, and statistical information are all managed by Aura.
- IF NOT EXISTS
Issues a notice rather than throwing an error if a table with the same name already exists.
- schema_name
The name of the database to which the table belongs. If no database name is specified, the table is created within the current_schema.
- table_name
The name of the table to be created, which should not exceed 63 characters in length.
- col_name
The name of the column to be created in the table, also limited to 63 characters. The combined total of regular and partition columns must not exceed 5,000.
- col_type
The data type of the column to be created, with supported ranges as follows:
Column Type
Can Be Declared As Partition Column
ORC Format
Parquet Format
Iceberg Format
Lance Format
SmallInt
√
√
√
√
√
Int
√
√
√
√
√
BigInt
√
√
√
√
√
Float
×
√
√
√
√
Double
×
√
√
√
√
Decimal
√
√
√
√
√
Numeric
√
√
√
√
√
Timestamp
√
√
√
√
√
Timestamptz
√
√
√
√
√
Date
√
√
√
√
√
Varchar
√
√
√
√
√
Char
√
√
√
√
√
Bool
×
√
√
√
√
Bytea
×
√
√
√
√
Text
√
√
√
√
√
Array
×
√
√
√
√
Struct
×
√
√
√
√
- col_comment
Comment for the column, which can be any string.
- table_comment
Comment for the table, which can also be any string.
- bucket_num
Number of buckets.
- option_key = option_value
Setting parameters at the table level, with supported parameter ranges as follows:
Table 1 Value range of the option_key parameter option_key
option_value
Description
Applicable Scope
orc.compress
zstd, snappy, lz4, uncompressed
Compression method for ORC files.
ORC
orc.stripe.byte.size
An integer greater than or equal to 1,000,000
Stripe size of an ORC file
parquet.compression
zstd, snappy, lz4, uncompressed
Compression method for Parquet files.
Parquet
parquet.compression-level
An integer ranging from –131,072 to 22
Compression mode for writing data to a Parquet table next time. The compression level can be specified only when the zstd algorithm is used. The value ranges from –131,072 to 22, and the default value is 1.
parquet.row.group.byte.size
An integer greater than or equal to 1,000,000
Row group size of a Parquet file
parquet.page.size
Integer
Page size of a Parquet file
parquet.dictionary.page.size
Integer
Dictionary size of a Parquet file
julian_adjust
true, false
Whether to convert to Julian date.
parquet.bloom.filter.enabled.column.col
true, false
Whether to write the col1 column to the Bloom filter index
checkencoding
high, low, no
Whether to check character encoding.
ORC, Parquet
column_index_access
true, false
Matching method between table-defined columns and file columns during reading. Defaults to true for column index matching, false for column name matching.
filesize
An integer ranging from 1 to 1024
Size of external table files generated.
write.delete.mode
copy-on-write, merge-on-read
Mode setting for deletion: cow or mor.
Iceberg
write.update.mode
copy-on-write, merge-on-read
Mode setting for updates: cow or mor.
write.merge.mode
copy-on-write, merge-on-read
Mode setting for merges: cow or mor.
format-version
2 and 3
Iceberg table version
write.parquet.compression-codec
zstd, lz4, snappy, gzip, uncompressed
Compression method for Parquet files.
write.parquet.compression-level
An integer ranging from –131,072 to 22
Compression level for writing the data in an Iceberg table to a Parquet file next time using the zstd algorithm. The compression level can be specified only when the zstd algorithm is used. The value ranges from –131,072 to 22, and the default value is 1.
If the behavior of this option is inconsistent with the default behavior of Iceberg, the formats that are not supported by Iceberg do not take effect by default, and the compression level can be specified for gzip.
write.merge.isolation-level
snapshot, serializable
Isolation level for merge commands.
write.metadata.delete-after-commit.enabled
true, false
Controls whether the oldest tracked version metadata file is deleted after committing.
write.update.isolation-level
snapshot, serializable
Isolation level for update commands.
write.delete.isolation-level
snapshot, serializable
Isolation level for delete commands.
write.metadata.previous-versions-max
An integer greater than 0
Number of older metadata files to retain.
write.parquet.bloom-filter-enabled.column.col1
true, false
Whether to write the col1 column to the bloom filter index.
metafile_location
metadata.json path
metadata.json path specified for creating an external Iceberg table
commit.retry.num-retries
An integer greater than 0
Number of retries upon a commit failure
commit.retry.min-wait-ms
An integer greater than 0
Minimum wait time after a failed commit
commit.retry.max-wait-ms
An integer greater than 0
Maximum time to wait before retrying a commit
commit.retry.total-timeout-ms
An integer greater than 0
Total retry timeout period for a commit
write.parquet.row-group-size-bytes
An integer greater than 0
Row group size of a Parquet file
write.parquet.page-size-bytes
An integer greater than 0
Page size of a Parquet file
write.parquet.page-row-limit
An integer greater than 0
Maximum number of rows on a Parquet file page
write.parquet.dict-size-bytes
An integer greater than 0
Dictionary size of a Parquet file
write.parquet.bloom-filter-max-bytes
An integer greater than 0
Maximum number of bytes for a bloom filter bitset
write.target-file-size-bytes
An integer greater than 0
Size of the Parquet file
write.delete.target-file-size-bytes
An integer greater than 0
Size of the delete file
write.format.default
parquet
Format of the data written to an Iceberg file. Only parquet is supported.
header
true, false
Whether the CSV file includes a header row with column names.
CSV
separatorChar
Single-byte character (not \r or \n)
Field delimiter for CSV data files. Defaults to , if not set.
quoteChar
Single-byte character. Must differ from the delimiter and null parameters.
Defines the character recognized as a quotation mark in CSV files. Default is double quotes (").
escapeChar
Single-byte character
Escape character in CSV files. Defaults to the same value as quoteChar.
field.delim
Single-byte character, which cannot be '\\.abcdefghijklmnopqrstuvwxyz0123456789'
Field delimiter for TEXT data files. Defaults to \t if not set.
Text
serialization.null.format
Single-byte character
Null values in data files. Defaults to \n.
escape.delim
Single-byte character
Escape character in TEXT files. Defaults to the same value as quoteChar.
line.delim
Single-byte character
Line delimiter style in data files. Defaults to \n.
drop.empty.lines
true, false
Whether to discard empty lines or single-line \n, \r, and \t in the text.
fill_missing_fields
true, false
Whether to report an error when the number of columns in the result of splitting a line by field.delim is less than the number of columns.
ignore_extra_data
true, false
Whether to report an error when the number of columns in the result of splitting a line by field.delim is greater than the number of columns.
skip.empty.files
true, false
Whether to read the JSON object whose content is '{}'. The default value is false.
JSON
nested.separator
Single-byte character, which cannot be a number sign (#).
Delimiter for nested JSON key concatenation. For example, if you set the delimiter to an underscore (_), {"a":{"b":1}} is mapped to column a_b, and the value of column a_b is 1. By default, nested JSON read and write are not supported.
ignore.nul.fields
true, false
Whether to skip writing keys with NULL values when writing a JSON object. The default value is false.
max.rows.per.file
An integer from 1 to 9,223,372,036,854,775,807
Maximum number of rows that can be written to a file
Lance, Text, CSV, JSON
enable.blob
true, false
Whether to use BLOB for this column
Lance
arrow.fixed-size-list
An integer from 1 to 2,147,483,647
Number of items in each row for FixedSizeList
max.bytes.per.file
An integer from 1 to 9,223,372,036,854,775,807
Maximum number of bytes that can be written to a file
lance.encoding.compression
A string, which can be zstd, lz4, or fsst
Compression mode for writing data to a Lance table next time. The compression level can be specified only when the zstd algorithm is used. The value ranges from 0 to 22, for example, zstd:22.
lance.batch.readahead
An integer from 1 to 9,223,372,036,854,775,807
Number of batches to be prefetched
lance.fragment.readahead
An integer from 1 to 9,223,372,036,854,775,807
Number of fragments to be prefetched
lance.storage.version
A string, which can be 0.1, 2.0, 2.1, or 2.2
Version of the Lance storage format
lance.block.size
An integer from 1 to 34,359,738,368
Minimum number of bytes in a single I/O request sent to the storage layer
metadata.cache.size
An integer from 1 to 34,359,738,368
Size of the metadata cache, in bytes
io.buffer.size
An integer from 1 to 34,359,738,368
Size of the I/O buffer, in bytes
index.cache.size
An integer from 1 to 34,359,738,368
Size of the index cache, in bytes
- table_format
Table storage format. The ORC, Parquet, Iceberg, Text, JSON, CSV, and Lance formats are supported.
Text, JSON, and CSV support only basic data import and export and do not support advanced functions, such as partitioning and ANALYZE operations. Therefore, they are not recommended as data storage or processing media.
- table_path
Table storage path. The value must be a valid OBS path. OBS buckets and parallel file systems are supported. If the path is an OBS bucket path, the table is read-only. Otherwise, the table can be read and written. If the table to be created is a managed table, the table storage path cannot be specified. The table storage path is specified by the system as the path with the same name as the table name in the schema path, and the path must be empty during table creation.
- select_stmt
Query statement. External tables do not support CTAS statements.
- table_format
Examples
Create an ORC table.
1 | CREATE TABLE test_table1 (a int, b bool, c text) store as orc; |
For details about how to create an Iceberg expression-partitioned table, see Creating an Expression-Partitioned Tables.
What is your overall rating for this page?
Thank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot