Skip to content

Commit d8faea8

Browse files
committed
make force-parsers
1 parent 1933735 commit d8faea8

2 files changed

Lines changed: 34 additions & 4 deletions

File tree

sdks/go/src/parser.go

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -572,6 +572,19 @@ func dictFromList(pairs [][]interface{}) map[string]interface{} {
572572
return result
573573
}
574574

575+
// stringMapFromPairs builds map[string]string from (prop key value) pair rows.
576+
func stringMapFromPairs(pairs [][]interface{}) map[string]string {
577+
out := make(map[string]string)
578+
for _, pair := range pairs {
579+
if len(pair) >= 2 {
580+
k, _ := pair[0].(string)
581+
v, _ := pair[1].(string)
582+
out[k] = v
583+
}
584+
}
585+
return out
586+
}
587+
575588
// dictGetValue retrieves a Value from the config dict with type assertion
576589
func dictGetValue(m map[string]interface{}, key string) *pb.Value {
577590
if v, ok := m[key]; ok {
@@ -843,11 +856,11 @@ func (p *Parser) construct_export_csv_config_with_source(path string, csv_source
843856
}
844857

845858
func (p *Parser) construct_iceberg_config(catalog_uri string, scope_opt *string, property_pairs [][]interface{}, auth_property_pairs [][]interface{}) *pb.IcebergConfig {
846-
props := dictFromList(property_pairs)
847-
auth_props := dictFromList(auth_property_pairs)
859+
props := stringMapFromPairs(property_pairs)
860+
auth_props := stringMapFromPairs(auth_property_pairs)
848861
_t2098 := p.iceberg_optional_string_field(scope_opt)
849862
scope_pb := _t2098
850-
_t2099 := &pb.IcebergConfig{CatalogUri: catalog_uri, Scope: deref(scope_pb, ""), Properties: props, AuthProperties: auth_props}
863+
_t2099 := &pb.IcebergConfig{CatalogUri: catalog_uri, Scope: scope_pb, Properties: props, AuthProperties: auth_props}
851864
return _t2099
852865
}
853866

@@ -862,7 +875,7 @@ func (p *Parser) iceberg_optional_string_field(s *string) *string {
862875

863876
func (p *Parser) construct_export_iceberg_config_full(locator *pb.IcebergLocator, config *pb.IcebergConfig, columns []*pb.IcebergExportColumn, config_dict [][]interface{}) *pb.ExportIcebergConfig {
864877
prefix := ""
865-
target_file_size_bytes := 0
878+
target_file_size_bytes := int64(0)
866879
compression := ""
867880
if config_dict != nil {
868881
cfg := dictFromList(config_dict)

sdks/go/src/pretty.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,23 @@ func listSort(pairs [][]interface{}) [][]interface{} {
261261
return pairs
262262
}
263263

264+
// dictToPairs converts map[string]string to sorted key/value rows for pretty printing.
265+
func dictToPairs(m map[string]string) [][]interface{} {
266+
if len(m) == 0 {
267+
return nil
268+
}
269+
keys := make([]string, 0, len(m))
270+
for k := range m {
271+
keys = append(keys, k)
272+
}
273+
sort.Strings(keys)
274+
out := make([][]interface{}, 0, len(keys))
275+
for _, k := range keys {
276+
out = append(out, []interface{}{k, m[k]})
277+
}
278+
return out
279+
}
280+
264281
// --- Free functions ---
265282

266283
func uint128ToString(low, high uint64) string {

0 commit comments

Comments
 (0)