DROP TABLE IF EXISTS {{ schema }}.one_row;
CREATE EXTERNAL TABLE IF NOT EXISTS {{ schema }}.one_row (number_of_rows INT COMMENT 'some comment')
COMMENT 'table comment'
ROW FORMAT DELIMITED FIELDS TERMINATED BY '\t' LINES TERMINATED BY '\n' STORED AS TEXTFILE
LOCATION '{{ s3_staging_dir }}{{ schema }}/one_row/';

CREATE OR REPLACE VIEW {{ schema }}.view_one_row AS SELECT * FROM {{ schema }}.one_row;

DROP TABLE IF EXISTS {{ schema }}.many_rows;
CREATE EXTERNAL TABLE IF NOT EXISTS {{ schema }}.many_rows (
    a INT
)
ROW FORMAT DELIMITED FIELDS TERMINATED BY '\t' LINES TERMINATED BY '\n' STORED AS TEXTFILE
LOCATION '{{ s3_staging_dir }}{{ schema }}/many_rows/';

DROP TABLE IF EXISTS {{ schema }}.one_row_complex;
CREATE EXTERNAL TABLE IF NOT EXISTS {{ schema }}.one_row_complex (
    col_boolean BOOLEAN,
    col_tinyint TINYINT,
    col_smallint SMALLINT,
    col_int INT,
    col_bigint BIGINT,
    col_float FLOAT,
    col_double DOUBLE,
    col_string STRING,
    col_varchar VARCHAR(10),
    col_timestamp TIMESTAMP,
    col_date DATE,
    col_binary BINARY,
    col_array ARRAY<int>,
    col_map MAP<int, int>,
    col_struct STRUCT<a: int, b: int>,
    col_decimal DECIMAL(10,1)
)
ROW FORMAT DELIMITED FIELDS TERMINATED BY '\t' LINES TERMINATED BY '\n' STORED AS TEXTFILE
LOCATION '{{ s3_staging_dir }}{{ schema }}/one_row_complex/';

DROP TABLE IF EXISTS {{ schema }}.partition_table;
CREATE EXTERNAL TABLE IF NOT EXISTS {{ schema }}.partition_table (
    a STRING
)
PARTITIONED BY (b INT)
ROW FORMAT DELIMITED FIELDS TERMINATED BY '\t' LINES TERMINATED BY '\n' STORED AS TEXTFILE
LOCATION '{{ s3_staging_dir }}{{ schema }}/partition_table/';

DROP TABLE IF EXISTS {{ schema }}.integer_na_values;
CREATE EXTERNAL TABLE IF NOT EXISTS {{ schema }}.integer_na_values (
    a INT,
    b INT
)
ROW FORMAT DELIMITED FIELDS TERMINATED BY '\t' LINES TERMINATED BY '\n' STORED AS TEXTFILE
LOCATION '{{ s3_staging_dir }}{{ schema }}/integer_na_values/';

DROP TABLE IF EXISTS {{ schema }}.boolean_na_values;
CREATE EXTERNAL TABLE IF NOT EXISTS {{ schema }}.boolean_na_values (
    a BOOLEAN,
    b BOOLEAN
)
ROW FORMAT DELIMITED FIELDS TERMINATED BY '\t' LINES TERMINATED BY '\n' STORED AS TEXTFILE
LOCATION '{{ s3_staging_dir }}{{ schema }}/boolean_na_values/';

DROP TABLE IF EXISTS {{ schema }}.execute_many;
CREATE EXTERNAL TABLE IF NOT EXISTS {{ schema }}.execute_many (
    a INT,
    b STRING
)
ROW FORMAT DELIMITED FIELDS TERMINATED BY '\t' LINES TERMINATED BY '\n' STORED AS TEXTFILE
LOCATION '{{ s3_staging_dir }}{{ schema }}/execute_many/';

DROP TABLE IF EXISTS {{ schema }}.execute_many_pandas;
CREATE EXTERNAL TABLE IF NOT EXISTS {{ schema }}.execute_many_pandas (
    a INT,
    b STRING
)
ROW FORMAT DELIMITED FIELDS TERMINATED BY '\t' LINES TERMINATED BY '\n' STORED AS TEXTFILE
LOCATION '{{ s3_staging_dir }}{{ schema }}/execute_many_pandas/';

DROP TABLE IF EXISTS {{ schema }}.execute_many_pandas_unload_auto;
CREATE EXTERNAL TABLE IF NOT EXISTS {{ schema }}.execute_many_pandas_unload_auto (
  a INT,
  b STRING
)
ROW FORMAT DELIMITED FIELDS TERMINATED BY '\t' LINES TERMINATED BY '\n' STORED AS TEXTFILE
LOCATION '{{ s3_staging_dir }}{{ schema }}/execute_many_pandas_unload_auto/';

DROP TABLE IF EXISTS {{ schema }}.execute_many_pandas_unload_pyarrow;
CREATE EXTERNAL TABLE IF NOT EXISTS {{ schema }}.execute_many_pandas_unload_pyarrow (
    a INT,
    b STRING
)
ROW FORMAT DELIMITED FIELDS TERMINATED BY '\t' LINES TERMINATED BY '\n' STORED AS TEXTFILE
LOCATION '{{ s3_staging_dir }}{{ schema }}/execute_many_pandas_unload_pyarrow/';

DROP TABLE IF EXISTS {{ schema }}.execute_many_pandas_unload_fastparquet;
CREATE EXTERNAL TABLE IF NOT EXISTS {{ schema }}.execute_many_pandas_unload_fastparquet (
    a INT,
    b STRING
)
ROW FORMAT DELIMITED FIELDS TERMINATED BY '\t' LINES TERMINATED BY '\n' STORED AS TEXTFILE
LOCATION '{{ s3_staging_dir }}{{ schema }}/execute_many_pandas_unload_fastparquet/';

DROP TABLE IF EXISTS {{ schema }}.execute_many_arrow;
CREATE EXTERNAL TABLE IF NOT EXISTS {{ schema }}.execute_many_arrow (
    a INT,
    b STRING
)
ROW FORMAT DELIMITED FIELDS TERMINATED BY '\t' LINES TERMINATED BY '\n' STORED AS TEXTFILE
LOCATION '{{ s3_staging_dir }}{{ schema }}/execute_many_arrow/';

DROP TABLE IF EXISTS {{ schema }}.execute_many_arrow_unload;
CREATE EXTERNAL TABLE IF NOT EXISTS {{ schema }}.execute_many_arrow_unload (
    a INT,
    b STRING
)
ROW FORMAT DELIMITED FIELDS TERMINATED BY '\t' LINES TERMINATED BY '\n' STORED AS TEXTFILE
LOCATION '{{ s3_staging_dir }}{{ schema }}/execute_many_arrow_unload/';

DROP TABLE IF EXISTS {{ schema }}.parquet_with_compression;
CREATE EXTERNAL TABLE IF NOT EXISTS {{ schema }}.parquet_with_compression (
    a INT
)
STORED AS PARQUET
LOCATION '{{ s3_staging_dir }}{{ schema }}/parquet_with_compression/'
TBLPROPERTIES ('parquet.compress'='SNAPPY');
CREATE OR REPLACE VIEW {{ schema }}.v_one_row AS SELECT number_of_rows FROM {{ schema }}.one_row
