|
116 | 116 | %nonterm export_csv_config transactions.ExportCSVConfig |
117 | 117 | %nonterm export_csv_path String |
118 | 118 | %nonterm export_csv_source transactions.ExportCSVSource |
| 119 | +%nonterm export_iceberg_column transactions.ExportIcebergColumn |
| 120 | +%nonterm export_iceberg_column_source transactions.ExportIcebergColumns |
| 121 | +%nonterm export_iceberg_columns transactions.ExportIcebergColumns |
119 | 122 | %nonterm export_iceberg_config transactions.ExportIcebergConfig |
120 | 123 | %nonterm iceberg_catalog_config logic.IcebergCatalogConfig |
121 | 124 | %nonterm iceberg_catalog_config_scope String |
122 | 125 | %nonterm iceberg_data logic.IcebergData |
123 | | -%nonterm iceberg_export_column transactions.ExportIcebergColumn |
124 | 126 | %nonterm iceberg_locator logic.IcebergLocator |
125 | 127 | %nonterm iceberg_property_entry Tuple[String, String] |
126 | 128 | %nonterm iceberg_to_snapshot String |
@@ -1167,14 +1169,30 @@ iceberg_catalog_config |
1167 | 1169 | $10: Sequence[Tuple[String, String]] = builtin.dict_to_pairs($$.properties) |
1168 | 1170 | $14: Sequence[Tuple[String, String]] = builtin.dict_to_pairs($$.auth_properties) |
1169 | 1171 |
|
1170 | | -iceberg_export_column |
1171 | | - : "(" "iceberg_column" STRING relation_id type boolean_value ")" |
1172 | | - construct: $$ = transactions.ExportIcebergColumn(name=$3, column_data=$4, type=$5, nullable=$6) |
| 1172 | +export_iceberg_column |
| 1173 | + : "(" "iceberg_column" STRING type boolean_value ")" |
| 1174 | + construct: $$ = transactions.ExportIcebergColumn(name=$3, type=$4, nullable=$5) |
1173 | 1175 | deconstruct: |
1174 | 1176 | $3: String = $$.name |
1175 | | - $4: logic.RelationId = $$.column_data |
1176 | | - $5: logic.Type = $$.type |
1177 | | - $6: Boolean = $$.nullable |
| 1177 | + $4: logic.Type = $$.type |
| 1178 | + $5: Boolean = $$.nullable |
| 1179 | + |
| 1180 | +export_iceberg_column_source |
| 1181 | + : "(" "source_gnf_defs" relation_id* ")" |
| 1182 | + construct: $$ = transactions.ExportIcebergColumns(source_gnf_defs=transactions.ExportIcebergGnfDefs(defs=$3)) |
| 1183 | + deconstruct if builtin.has_proto_field($$, 'source_gnf_defs'): |
| 1184 | + $3: Sequence[logic.RelationId] = $$.source_gnf_defs.defs |
| 1185 | + | "(" "source_table_def" relation_id ")" |
| 1186 | + construct: $$ = transactions.ExportIcebergColumns(source_table_def=$3) |
| 1187 | + deconstruct if builtin.has_proto_field($$, 'source_table_def'): |
| 1188 | + $3: logic.RelationId = $$.source_table_def |
| 1189 | + |
| 1190 | +export_iceberg_columns |
| 1191 | + : "(" "columns" export_iceberg_column_source "(" "target_columns" export_iceberg_column* ")" ")" |
| 1192 | + construct: $$ = merge_export_iceberg_columns($3, $6) |
| 1193 | + deconstruct: |
| 1194 | + $3: transactions.ExportIcebergColumns = $$ |
| 1195 | + $6: Sequence[transactions.ExportIcebergColumn] = $$.target_columns |
1178 | 1196 |
|
1179 | 1197 | iceberg_to_snapshot |
1180 | 1198 | : "(" "to_snapshot" STRING ")" |
@@ -1311,14 +1329,14 @@ export_csv_source |
1311 | 1329 | $3: logic.RelationId = $$.table_def |
1312 | 1330 |
|
1313 | 1331 | export_iceberg_config |
1314 | | - : "(" "export_iceberg_config" iceberg_locator iceberg_catalog_config "(" "columns" iceberg_export_column* ")" "(" "create_table_properties" iceberg_property_entry* ")" config_dict? ")" |
1315 | | - construct: $$ = construct_export_iceberg_config_full($3, $4, $7, $11, $13) |
| 1332 | + : "(" "export_iceberg_config" iceberg_locator iceberg_catalog_config export_iceberg_columns "(" "table_properties" iceberg_property_entry* ")" config_dict? ")" |
| 1333 | + construct: $$ = construct_export_iceberg_config_full($3, $4, $5, $8, $10) |
1316 | 1334 | deconstruct: |
1317 | 1335 | $3: logic.IcebergLocator = $$.locator |
1318 | 1336 | $4: logic.IcebergCatalogConfig = $$.config |
1319 | | - $7: Sequence[transactions.ExportIcebergColumn] = $$.columns |
1320 | | - $11: Sequence[Tuple[String, String]] = builtin.dict_to_pairs($$.create_table_properties) |
1321 | | - $13: Optional[Sequence[Tuple[String, logic.Value]]] = deconstruct_export_iceberg_config_optional($$) |
| 1337 | + $5: transactions.ExportIcebergColumns = $$.columns |
| 1338 | + $8: Sequence[Tuple[String, String]] = builtin.dict_to_pairs($$.table_properties) |
| 1339 | + $10: Optional[Sequence[Tuple[String, logic.Value]]] = deconstruct_export_iceberg_config_optional($$) |
1322 | 1340 |
|
1323 | 1341 |
|
1324 | 1342 | %% |
@@ -1668,26 +1686,35 @@ def deconstruct_iceberg_data_to_snapshot_optional(msg: logic.IcebergData) -> Opt |
1668 | 1686 | def construct_export_iceberg_config_full( |
1669 | 1687 | locator: logic.IcebergLocator, |
1670 | 1688 | config: logic.IcebergCatalogConfig, |
1671 | | - columns: Sequence[transactions.ExportIcebergColumn], |
1672 | | - create_table_property_pairs: Sequence[Tuple[String, String]], |
| 1689 | + columns: transactions.ExportIcebergColumns, |
| 1690 | + table_property_pairs: Sequence[Tuple[String, String]], |
1673 | 1691 | config_dict: Optional[Sequence[Tuple[String, logic.Value]]], |
1674 | 1692 | ) -> transactions.ExportIcebergConfig: |
1675 | 1693 | cfg: Dict[String, logic.Value] = builtin.dict_from_list(builtin.unwrap_option_or(config_dict, list[Tuple[String, logic.Value]]())) |
1676 | 1694 | prefix: String = _extract_value_string(builtin.dict_get(cfg, "prefix"), "") |
1677 | 1695 | target_file_size_bytes: int = _extract_value_int64(builtin.dict_get(cfg, "target_file_size_bytes"), 0) |
1678 | 1696 | compression: String = _extract_value_string(builtin.dict_get(cfg, "compression"), "") |
1679 | | - create_table_props: Dict[String, String] = builtin.string_map_from_pairs(create_table_property_pairs) |
| 1697 | + table_props: Dict[String, String] = builtin.string_map_from_pairs(table_property_pairs) |
1680 | 1698 | return transactions.ExportIcebergConfig( |
1681 | 1699 | locator=locator, |
1682 | 1700 | config=config, |
1683 | 1701 | columns=columns, |
1684 | 1702 | prefix=builtin.some(prefix), |
1685 | 1703 | target_file_size_bytes=builtin.some(target_file_size_bytes), |
1686 | 1704 | compression=compression, |
1687 | | - create_table_properties=create_table_props, |
| 1705 | + table_properties=table_props, |
1688 | 1706 | ) |
1689 | 1707 |
|
1690 | 1708 |
|
| 1709 | +def merge_export_iceberg_columns( |
| 1710 | + source: transactions.ExportIcebergColumns, |
| 1711 | + target_columns: Sequence[transactions.ExportIcebergColumn], |
| 1712 | +) -> transactions.ExportIcebergColumns: |
| 1713 | + if builtin.has_proto_field(source, 'source_gnf_defs'): |
| 1714 | + return transactions.ExportIcebergColumns(source_gnf_defs=transactions.ExportIcebergGnfDefs(defs=source.source_gnf_defs.defs), target_columns=target_columns) |
| 1715 | + return transactions.ExportIcebergColumns(source_table_def=source.source_table_def, target_columns=target_columns) |
| 1716 | + |
| 1717 | + |
1691 | 1718 | def deconstruct_export_iceberg_config_optional( |
1692 | 1719 | msg: transactions.ExportIcebergConfig, |
1693 | 1720 | ) -> Optional[Sequence[Tuple[String, logic.Value]]]: |
|
0 commit comments