Skip to content

Commit

Permalink
[CALCITE-5621] Support UDT declarations from root of schema model. (a…
Browse files Browse the repository at this point in the history
…pache#7)

Related to CALCITE-5346.

Previously we relied on the parser to map unrecognized datatypes to a known type using SqlAlienSystemTypeNameSpec. This worked but made it difficult to change or add new types as necessary. One would have to update at least 3 different parsers (babel, core, server) to make a change.

This change allows for declaring user-defined types at the root of a schema model and allows for easy type alias mapping. These data types are shared by all schema in the model so cast and DDL expressions do not need to scope data type references to a particular sub-schema.

For example:
```
inline: {
  version: '1.0',
  types: [
    {
      name: 'BOOL',
      type: 'BOOLEAN'
    },
    {
      name: 'BYTES',
      type: 'VARBINARY'
    },
...
  ],
```
Allows for `CAST("true" as BOOL)`
  • Loading branch information
tjbanghart authored and olivrlee committed Aug 18, 2023
1 parent 7911a54 commit 5344035
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions core/src/main/java/org/apache/calcite/model/JsonRoot.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,7 @@ public class JsonRoot {
*/
public final List<JsonSchema> schemas = new ArrayList<>();

/** List of types in the root schema.
*
* <p>Such types global, that is, shared by all schemas in the model.
/** Types in the root schema. Shared by all schemas in the model.
*
* <p>The list may be empty.
*/
Expand Down

0 comments on commit 5344035

Please sign in to comment.