Skip to content

Expose parseColumnType function #316

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
merged 6 commits into from
Sep 23, 2024
Merged

Expose parseColumnType function #316

merged 6 commits into from
Sep 23, 2024

Conversation

slvrtrn
Copy link
Contributor

@slvrtrn slvrtrn commented Sep 18, 2024

Summary

Extracted and exported the parseColumnType method from the #257 branch. Related to #273.
This is useful not only for RowBinary/Native protocols but also for TS interface codegens, so it is probably worth adding it right away.

For example:

  • Input type: Array(Array(DateTime('Etc/GMT-5')))
  • Output object:
{
  sourceType: `Array(Array(DateTime('Etc/GMT-5')))`,
  type: 'Array',
  dimensions: 2,
  value: {
    type: 'DateTime',
    timezone: 'Etc/GMT-5',
    sourceType: `DateTime('Etc/GMT-5')`,
  },
}

Currently supported types to parse:

  • Bool
  • UInt8
  • Int8
  • UInt16
  • Int16
  • UInt32
  • Int32
  • UInt64
  • Int64
  • UInt128
  • Int128
  • UInt256
  • Int256
  • Float32
  • Float64
  • String
  • FixedString(N)
  • UUID
  • Date
  • Date32
  • IPv4
  • IPv6
  • Array (arbitrary nesting)
  • Map (arbitrary nesting)
  • Tuple (arbitrary nesting)
  • Enum (including enums in arrays, maps, tuples)
  • DateTime (including timezones)
  • DateTime64 (including timezones and various precisions)
  • Decimal
  • Nullable, LowCardinality combinations

Currently, not supported (will throw):

  • Geo
  • (Simple)AggregateFunction
  • Nested
  • Old/new JSON
  • Dynamic
  • Variant

Please take a look at the tests for more examples.
The tests are not fully complete, so this will be somewhat "experimental" still.

Checklist

  • Unit and integration tests covering the common scenarios were added
  • A human-readable description of the changes was provided to include in CHANGELOG
  • For significant changes, documentation in https://github.com/ClickHouse/clickhouse-docs was updated with further explanations or tutorials

@slvrtrn slvrtrn changed the title Expose parseColumnType method Expose parseColumnType function Sep 23, 2024
Copy link

@slvrtrn slvrtrn merged commit 9ab44fb into main Sep 23, 2024
27 checks passed
@slvrtrn slvrtrn deleted the column-types branch September 23, 2024 18:04
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants