[ https://issues.apache.org/jira/browse/CALCITE-2045?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16254217#comment-16254217 ]
Julian Hyde commented on CALCITE-2045: -------------------------------------- Here's what's in the SQL standard (verbatim, but I've removed some lines): {noformat} <user-defined type definition> ::= CREATE TYPE <user-defined type body> <user-defined type body> ::= <schema-resolved user-defined type name> [ <subtype clause> ] [ AS <representation> ] [ <user-defined type option list> ] [ <method specification list> ] <user-defined type option list> ::= <user-defined type option> [ <user-defined type option>... ] <user-defined type option> ::= <instantiable clause> | <finality> | <reference type specification> | <cast to ref> | <cast to type> | <cast to distinct> | <cast to source> <subtype clause> ::= UNDER <supertype name> <supertype name> ::= <path-resolved user-defined type name> <representation> ::= <predefined type> | <collection type> | <member list> <member list> ::= <left paren> <member> [ { <comma> <member> }... ] <right paren> <member> ::= <attribute definition> <instantiable clause> ::= INSTANTIABLE | NOT INSTANTIABLE <finality> ::= FINAL | NOT FINAL <attribute definition> ::= <attribute name> <data type> [ <attribute default> ] [ <collate clause> ] <attribute default> ::= <default clause> {noformat} Of the features in the standard, I don't think we should allow {{<user-defined type option>}} or {{<subtype clause>}} or {{<collection type>}} at this point. We might add them later. I don't think we should allow distinct types to be flagged {{NULL}} or {{NOT NULL}}. I think we should add {{OR REPLACE}}, consistent with other Calcite {{CREATE}} commands. Which gives us this: {noformat} CREATE [ OR REPLACE ] TYPE [ schema_name. ] type_name { AS base_type | AS ( attributeDef [, attributeDef ]* ) } attributeDef: attribute_name data_type [ COLLATE collation ] [ NULL | NOT NULL ] [ DEFAULT expression ] {noformat} Examples: {code} CREATE TYPE metric_meter AS DOUBLE; CREATE OR REPLACE TYPE imperial_foot AS DOUBLE; CREATE TYPE mySchema.Circle AS ( radius DOUBLE DEFAULT 1 ); {code} There is a [very nice write-up of SQL UDTs in Farrago|http://farrago.sourceforge.net/design/UserDefinedTypesAndRoutines.html], an ancestor project of Calcite. We could mine that for further examples. > Support "CREATE TYPE" DDL > ------------------------- > > Key: CALCITE-2045 > URL: https://issues.apache.org/jira/browse/CALCITE-2045 > Project: Calcite > Issue Type: New Feature > Components: core > Reporter: Shuyi Chen > Assignee: Julian Hyde > -- This message was sent by Atlassian JIRA (v6.4.14#64029)