Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create a Presto table with a column as an Array datatype

Tags:

presto

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)...

like image 407
Brighid Meredith Avatar asked Jul 03 '18 17:07

Brighid Meredith


People also ask

How to make table in presto?

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.

How do I create an external table in Presto?

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.

How do I check my Presto data type?

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.


Video Answer


1 Answers

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.

like image 103
Piotr Findeisen Avatar answered Oct 23 '22 05:10

Piotr Findeisen