How does one create a table in Presto with one of the columns having an Array datatype?
For example:
CREATE TABLE IF NOT EXISTS (ID BIGINT, ARRAY_COL ARRAY)...
Create a new, empty table with the specified columns. Use CREATE TABLE AS to create a table with data. The optional IF NOT EXISTS clause causes the error to be suppressed if the table already exists. The LIKE clause can be used to include all the column definitions from an existing table in the new table.
Presto does not support creating external tables in Hive (both HDFS and S3). If you want to create a table in Hive with data in S3, you have to do it from Hive. Also, CREATE TABLE.. AS query, where query is a SELECT query on the S3 table will not create the table on S3.
Presto has a typeof() function to make finding out data types of values easy. This is particularly useful when you are getting values from nested maps for example and the data types need to be determined. Armed with this info you should now be able to find out the data types of values.
Edit
The syntax for array type is array(element_type)
, like this:
create table memory.default.t (a array(varchar));
Original answer
The syntax for array type is array<element_type>
, like this:
create table memory.default.t (a array<varchar>);
Note: the connector in which you create the table must support the array data type and not every connector supports it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With