[jira] [Commented] (CALCITE-2045) Support "CREATE TYPE" DDL

2018-03-14 Thread Shuyi Chen (JIRA)

[ 
https://issues.apache.org/jira/browse/CALCITE-2045?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16399352#comment-16399352
 ] 

Shuyi Chen commented on CALCITE-2045:
-

[~julianhyde], sounds good to me. Can you take another look at the PR at your 
convenience? thanks.

> 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: Shuyi Chen
>Priority: Major
>




--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (CALCITE-2045) Support "CREATE TYPE" DDL

2018-03-14 Thread Julian Hyde (JIRA)

[ 
https://issues.apache.org/jira/browse/CALCITE-2045?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16399234#comment-16399234
 ] 

Julian Hyde commented on CALCITE-2045:
--

Sorry, [~jcamachorodriguez] already started a vote for RC0, so it will miss 
1.16. Let's carry on working on it, and it will be in 1.17.

> 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: Shuyi Chen
>Priority: Major
>




--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (CALCITE-2045) Support "CREATE TYPE" DDL

2018-03-13 Thread Shuyi Chen (JIRA)

[ 
https://issues.apache.org/jira/browse/CALCITE-2045?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16397766#comment-16397766
 ] 

Shuyi Chen commented on CALCITE-2045:
-

Hi [~julianhyde], do you think if we can get this in 1.16? Thanks a lot.

> 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: Shuyi Chen
>Priority: Major
>




--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (CALCITE-2045) Support "CREATE TYPE" DDL

2018-03-09 Thread Shuyi Chen (JIRA)

[ 
https://issues.apache.org/jira/browse/CALCITE-2045?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16393765#comment-16393765
 ] 

Shuyi Chen commented on CALCITE-2045:
-

Hi [~julianhyde], I addressed all comments, could you please take another look 
at the PR? Thanks a lot.

> 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: Shuyi Chen
>Priority: Major
>




--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (CALCITE-2045) Support "CREATE TYPE" DDL

2018-02-28 Thread Julian Hyde (JIRA)

[ 
https://issues.apache.org/jira/browse/CALCITE-2045?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16380943#comment-16380943
 ] 

Julian Hyde commented on CALCITE-2045:
--

Reviewing 
[2add2e4|https://github.com/apache/calcite/pull/638/commits/2add2e4dfd0916aea8061391c91f8148066981db]:
* It's a very good start. You've got the design exactly as I'd have done it.
* A few places (e.g. the `typeEntry` method, and in `JsonRoot`) you have 
copy-pasted "table" stuff to "type", but haven't fixed all the comments.
* I'd rename `JsonAttribute` to `JsonTypeAttribute`
* for completeness we need a `DROP TYPE [IF EXISTS]` statement
* I don't like moving `SqlDdlNodes.schema` to `Util`. Maybe you need to create 
`SqlValidatorUtil.getTypeEntry` similar to `getTableEntry`. And leave 
`SqlDdlNodes.schema` where it is.
* The new error message in SqlValidatorTest.testCastFails is not good enough. 
Should not contain 'UnsupportedOperationException'
* Need more tests in `SqlValidatorTest` (positive and negative, e.g. types 
qualified by schema, referencing a type attribute 
* Need a new test `type.iq` similar to `server/src/test/resources/sql/table.iq`
* Need some new sections in `model.md`
* In `reference.md`, don't use underscores; other identifiers are camel-case


> 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: Shuyi Chen
>Priority: Major
>




--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (CALCITE-2045) Support "CREATE TYPE" DDL

2018-02-27 Thread Shuyi Chen (JIRA)

[ 
https://issues.apache.org/jira/browse/CALCITE-2045?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16379730#comment-16379730
 ] 

Shuyi Chen commented on CALCITE-2045:
-

[~julianhyde], initial [PR|https://github.com/apache/calcite/pull/638], could 
you please help take a look?

> 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: Shuyi Chen
>Priority: Major
>




--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (CALCITE-2045) Support "CREATE TYPE" DDL

2018-02-07 Thread Julian Hyde (JIRA)

[ 
https://issues.apache.org/jira/browse/CALCITE-2045?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16356593#comment-16356593
 ] 

Julian Hyde commented on CALCITE-2045:
--

Don't add that kind of stuff to {{SqlDataTypeSpec}}. As a sub-class of 
{{SqlNode}}, it is an AST node, and should only have the information in the raw 
SQL; nothing should be 'resolved'.

It is the validator's job to figure out types. For an expression, you call 
{{RelDataType SqlValidator.getValidatedNodeType(SqlNode)}}. For a 
{{SqlDataTypeSpec}}, you could actually call the same method. It will use the 
{{SqlValidatorCatalogReader}} inside the validator. This has methods 
{{CalciteSchema getRootSchema()}} and {{RelDataType getNamedType(SqlIdentifier 
typeName)}}, both of which you will find useful.

> 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: Shuyi Chen
>Priority: Major
>




--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (CALCITE-2045) Support "CREATE TYPE" DDL

2018-02-07 Thread Shuyi Chen (JIRA)

[ 
https://issues.apache.org/jira/browse/CALCITE-2045?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16356429#comment-16356429
 ] 

Shuyi Chen commented on CALCITE-2045:
-

Hi [~julianhyde], I think I'll need to extend SqlDataTypeSpec to pass the 
schema (or something equivalence to provide access to the registered UDT) 
during SqlDataTypeSpec.deriveType call. Otherwise, after I create a type using 
"_CREATE TYPE mytype1 as int_", when I use the type to, say, _create table t (c 
mytype1),_ it will fail. Because the type info is only registered in the 
schema, and SqlDataTypeSpec has to access the created user-defined type through 
schema. However, this might be difficult because not all call sites of 
SqlDataTypeSpec.deriveType can provide access to the schema. If this is the 
right option, I can try to modify all call sites to provide access to the 
schema directly or indirectly.  Do you have any suggestions? 

> 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: Shuyi Chen
>Priority: Major
>




--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (CALCITE-2045) Support "CREATE TYPE" DDL

2018-02-03 Thread Julian Hyde (JIRA)

[ 
https://issues.apache.org/jira/browse/CALCITE-2045?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16351570#comment-16351570
 ] 

Julian Hyde commented on CALCITE-2045:
--

For CREATE TYPE, you will need a SqlCreateType class similar to SqlCreateTable.

I think you will also need to allow a reference to a user-defined type in 
SqlDataTypeSpec (or a sub-class of SqlDataTypeSpec; I'm not sure). That change 
should go into core, and be accompanied by tests in SqlParserTest. In common 
with other code, the parser should not check whether the referenced type 
exists. It should just produce a parse tree.

Then you will need to extend the validator to resolve type identifiers (and 
convert to fully-qualified names). Probably at that point you will convert to 
RelDataType.

> 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
>Priority: Major
>




--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (CALCITE-2045) Support "CREATE TYPE" DDL

2018-02-02 Thread Shuyi Chen (JIRA)

[ 
https://issues.apache.org/jira/browse/CALCITE-2045?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16351203#comment-16351203
 ] 

Shuyi Chen commented on CALCITE-2045:
-

Hi [~julianhyde], shall we also extend SqlDataTypeSpec and the parser to 
support complex type expressions like:

 
{code:java}
ROW(NUMBER(5, 2) NOT NULL AS foo, ROW(BOOLEAN AS b, MyUDT NOT NULL AS i) AS rec)
{code}
However, the grammar might be slightly different than the grammar in what we 
discussed above in "CREATE TYPE",  i.e.,

 
{code:java}
CREATE TYPE myType AS (b BOOLEAN, i MyUDT NOT NULL)
CREATE TYPE myType2 AS (foo NUMBER(5, 2) NOT NULL, rec myType){code}
Should we converge them, or leave them as 2 different parser implementations? 
Thanks a lot.

> 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
>Priority: Major
>




--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (CALCITE-2045) Support "CREATE TYPE" DDL

2017-11-29 Thread Shuyi Chen (JIRA)

[ 
https://issues.apache.org/jira/browse/CALCITE-2045?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16272210#comment-16272210
 ] 

Shuyi Chen commented on CALCITE-2045:
-

Thanks, [~julianhyde]. I saw CALCITE-707 is resolved. I will work on adding the 
"CREATE TYPE" DDL on top of it.

> 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)


[jira] [Commented] (CALCITE-2045) Support "CREATE TYPE" DDL

2017-11-16 Thread Julian Hyde (JIRA)

[ 
https://issues.apache.org/jira/browse/CALCITE-2045?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16256130#comment-16256130
 ] 

Julian Hyde commented on CALCITE-2045:
--

Definitely not part of CALCITE-707. You could wait until it goes in, or you 
could start developing in a branch based on a stable point in my branch, 
https://github.com/julianhyde/calcite/tree/707-ddl (for example, at 
https://github.com/julianhyde/calcite/commit/3b849a819a4470da3f91b31c242e80e29578df7d
 everything up to CREATE TABLE was working) and I'll help you rebase after 707 
is committed.

> 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)


[jira] [Commented] (CALCITE-2045) Support "CREATE TYPE" DDL

2017-11-16 Thread Shuyi Chen (JIRA)

[ 
https://issues.apache.org/jira/browse/CALCITE-2045?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16256078#comment-16256078
 ] 

Shuyi Chen commented on CALCITE-2045:
-

Thanks, [~julianhyde]. I think that looks good to me as the first version. Are 
you planning to add it in Calcite-707 or we can implement it after it?

> 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)


[jira] [Commented] (CALCITE-2045) Support "CREATE TYPE" DDL

2017-11-15 Thread Julian Hyde (JIRA)

[ 
https://issues.apache.org/jira/browse/CALCITE-2045?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=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}
 ::=
CREATE TYPE 
 ::=

[  ]
[ AS  ]
[  ]
[  ]
 ::=
 [ ... ]
 ::=

  | 
  | 
  | 
  | 
  | 
  | 
 ::=
UNDER 
 ::=

 ::=

  | 
  | 
 ::=
  [ {   }... ] 
 ::=

 ::=
INSTANTIABLE
  | NOT INSTANTIABLE
 ::=
FINAL
  | NOT FINAL
 ::=
 
  [  ]
  [  ]
 ::=

{noformat}

Of the features in the standard, I don't think we should allow {{}} or {{}} or {{}} 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)


[jira] [Commented] (CALCITE-2045) Support "CREATE TYPE" DDL

2017-11-15 Thread Shuyi Chen (JIRA)

[ 
https://issues.apache.org/jira/browse/CALCITE-2045?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16253119#comment-16253119
 ] 

Shuyi Chen commented on CALCITE-2045:
-

Hi [~julianhyde], I think we can start with the following syntax to allow 
creating scalar type and composite(row) type

CREATE TYPE [ schema_name. ] type_name  
{   
FROM base_type   
[ NULL | NOT NULL ]   
  | AS ( [ attribute_name  [ COLLATE collation ] [ NULL | NOT NULL ] 
 [ ,...n ] )
} [ ; ]  

What do you think?

> 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)


[jira] [Commented] (CALCITE-2045) Support "CREATE TYPE" DDL

2017-11-10 Thread Julian Hyde (JIRA)

[ 
https://issues.apache.org/jira/browse/CALCITE-2045?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16248276#comment-16248276
 ] 

Julian Hyde commented on CALCITE-2045:
--

This would be perfect as part of the "server" module I am adding as part of 
CALCITE-707.

As a separate task, I also think we should add a type element to the JSON 
model, and "types" collection to the schema element in the JSON model, 
https://calcite.apache.org/docs/model.html#map-schema similar to its existing 
collections "tables" and "functions". It is probably better to do that task 
first, then it will be simple to add DDL support later.

Can you describe what syntax you were thinking for "CREATE TYPE"?

> 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)


[jira] [Commented] (CALCITE-2045) Support "CREATE TYPE" DDL

2017-11-10 Thread Shuyi Chen (JIRA)

[ 
https://issues.apache.org/jira/browse/CALCITE-2045?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16248028#comment-16248028
 ] 

Shuyi Chen commented on CALCITE-2045:
-

Hi [~julianhyde], what do you think of supporting this in Calcite DDL?

> 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)