dummy_tables function

Create dummy tables in Presto for testing

Create dummy tables in Presto for testing

create_primitive_arrays_table() creates a dummy table that has ARRAYs of primitive Presto data types.

create_primitive_maps_table() creates a dummy table that has MAPs of primitive Presto data types.

create_primitive_types_table() creates a dummy table that has primitive Presto data types.

create_primitive_rows_table() creates a dummy table that has all primitive data types included in one ROW type column.

create_array_of_rows_table() creates a dummy table that has an ARRAY(ROW)

column that has 2 ROW elements, each containing all 17 supported primitive data types.

create_array_of_maps_table() creates a dummy table that has 17 ARRAY(MAP)

columns, each of which has an ARRAY of 2 MAP elements.

create_primitive_arrays_table( con, table_name = "presto_primitive_arrays", time_zone = "America/New_York", verbose = TRUE ) create_primitive_maps_table( con, table_name = "presto_primitive_maps", time_zone = "America/New_York", verbose = TRUE ) create_primitive_types_table( con, table_name = "presto_primitive_types", time_zone = "America/New_York", verbose = TRUE ) create_primitive_rows_table( con, table_name = "presto_primitive_rows", time_zone = "America/New_York", verbose = TRUE ) create_array_of_rows_table( con, table_name = "presto_array_of_rows", time_zone = "America/New_York", verbose = TRUE ) create_array_of_maps_table( con, table_name = "presto_array_of_maps", time_zone = "America/New_York", verbose = TRUE )

Arguments

  • con: A valid PrestoConnection object.
  • table_name: The resulting table name.
  • time_zone: Time zone string for data types that require a time zone. Default to "America/New_York".
  • verbose: Boolean indicating whether messages should be printed. Default to TRUE.

Details

We construct the arrays-of-primitive-types table by putting two different values of the same type and a NULL value in an array. In this way, the three values of the same type appear together in the source code and therefore are easier to compare. For integer values, we use the theoretical lower bound (i.e., minimum value) and the theoretical upper bound (i.e., maximum value) as the two values. The field names are taken from the Presto data types they represent.

Here's the complete primitive type values included in the table

IndexColumnTypeARRAY values
1booleanBOOLEAN[true, false, null]
2tinyintTINYINT[-128, 127, null]
3smallintSMALLINT[-32768, 32767, null]
4integerINTEGER[-2147483647, 2147483647, null]
5bigintBIGINT[-9007199254740991, 9007199254740991, null]
6realREAL[1.0, 2.0, null]
7doubleDOUBLE[1.0, 2.0, null]
8decimalDECIMAL[-9007199254740991.5, 9007199254740991.5, null]
9varcharVARCHAR['abc', 'def', null]
10charCHAR['a', 'b', null]
11varbinaryVARBINARY['abc', 'def', null]
12dateDATE['2000-01-01', '2000-01-02', null]
13timeTIME['01:02:03.456', '02:03:04.567', null]
14time_with_tzTIME WITH TIME ZONE['01:02:03.456 <tz>', '02:03:04.567 <tz>', null]
15timestampTIMESTAMP['2000-01-01 01:02:03.456', '2000-01-02 02:03:04.567', null]
16timestamp_with_tzTIMESTAMP WITH TIME ZONE['2000-01-01 01:02:03.456 <tz>', '2000-01-02 02:03:04.567 <tz>', null]
17interval_year_to_monthINTERVAL YEAR TO MONTH['14' MONTH, '28' MONTH, null]
18interval_day_to_secondINTERVAL DAY TO SECOND['2 4:5:6.500' DAY TO SECOND, '3 7:8:9.600' DAY TO SECOND, null]

We construct the maps-of-primitive-types table by first creating a table with ARRAYs of all primitive data types. We then use the MAP() function to create the MAPs from ARRAYs.

We construct the primitive-types table by first creating a table with ARRAYs of all primitive data types. We then use Presto's UNNEST() function to expand the arrays into three separate rows. Each supported Presto data type has three rows in the table so that the resulting R data frame is distinctly different from a simple named list.

We construct the primitive-rows table by first creating a table with all primitive data types. We then use Presto's CAST(ROW() AS ROW())

function to create the ROW column.

We construct the array-of-rows table by first creating a table with a ROW type column that includes all 17 supported primitive data types. We then use the ARRAY[] function to construct the 2-element ARRAY(ROW)

column.

We construct the array-of-maps table by first creating a table a primitive MAP table and then calling the ARRAY[] function to create the ARRAY(MAP) columns.

  • Maintainer: Jarod G.R. Meng
  • License: BSD_3_clause + file LICENSE
  • Last published: 2025-01-08