atoti.MultiRowArrayConversion#
- final class atoti.MultiRowArrayConversion#
Convert an external table where array values are stored with one value per row to a table with array columns.
The external table must have an
index_column
and at least one “value” column representing the array elements.All the table columns except from
index_column
and thearray_columns
will become key columns.Example
>>> external_database = session.connect_to_external_database(connection_config) >>> external_table = external_database.tables["TUTORIAL", "MULTI_ROW_QUANTITY"]
external_table
has an INDEX column:>>> list(external_table) ['PRODUCT', 'INDEX', 'QUANTITY']
and its content is:
PRODUCT
INDEX
QUANTITY
product_1
0
10.0
product_1
1
20.0
product_1
2
15.0
product_1
3
25.0
product_1
4
10.0
product_2
0
50.0
product_2
1
65.0
product_2
2
55.0
product_2
3
30.0
product_2
4
80.0
It can be converted into a table with an array column:
>>> table = session.add_external_table( ... external_table, ... config=TableConfig( ... array_conversion=tt.MultiRowArrayConversion( ... array_columns={"QUANTITY"}, ... index_column="INDEX", ... ), ... ), ... table_name="Sales (Multi row array)", ... ) >>> table.head().sort_index() QUANTITY PRODUCT product_1 [10.0, 20.0, 15.0, 25.0, 10.0] product_2 [50.0, 65.0, 55.0, 30.0, 80.0]