LucidDB / luciddb

DEFUNCT: See README
https://github.com/LucidDB/luciddb
Apache License 2.0
52 stars 24 forks source link

[FRG-153] cast ('foo' as char) gives unhelpful error message #719

Closed dynamobi-build closed 12 years ago

dynamobi-build commented 12 years ago

[reporter="johnk", created="Tue, 20 Jun 2006 19:59:49 -0500 (GMT-05:00)"] 0: jdbc:sqlstream://localhost> values cast ('foo' as char);
Error: java.lang.AssertionError: null (state=,code=0)

Null wasn't helpful to me.

This, OTOH, looks good:

0: jdbc:sqlstream://localhost> values cast ('foo' as char());
Error: org.eigenbase.sql.parser.SqlParseException: Encountered ")" at line 1, column 28.
Was expecting:
     ... (state=,code=0)

And it works if correctly specified:

0: jdbc:sqlstream://localhost> values cast ('foo' as char(10));
'EXPR$0'
'foo '
1 row selected (1.208 seconds)
0: jdbc:sqlstream://localhost>

dynamobi-build commented 12 years ago

[author="jvs", created="Wed, 21 Jun 2006 23:29:07 -0500 (GMT-05:00)"] There's an old TODO in the code here...this really ought to get fixed, so bumping up priority. If I remember correctly, this is actually supposed to be interpreted as char(1), but need to check the standard.

dynamobi-build commented 12 years ago

[author="jvs", created="Sun, 25 Jun 2006 18:45:45 -0500 (GMT-05:00)"] I checked the standard, and we should be defaulting to length 1 in this case. Part 2 Section 6.1 Syntax Rule 5.

Actually, DdlHandler.validateTypedElement already has the defaulting logic:

        if ((typeName != null) && typeName.allowsPrec()) {
            if (precision == null) {
                int p = typeName.getDefaultPrecision();
                if (p != -1) {
                    precision = new Integer(p);
                }
            }

However, this is only used for validating, but it doesn't update the catalog descriptor, so once it gets past this, the original descriptor gets read by SqlTypeFactoryImpl.createSqlType, leading to the same assertion for CREATE TABLE as in the query case noted by JohnK.

dynamobi-build commented 12 years ago

[author="jvs", created="Sun, 25 Jun 2006 18:46:32 -0500 (GMT-05:00)"] Angel, reassigning to you as part of resolving FRG-21 (per IM conversation today).

dynamobi-build commented 12 years ago

[author="angel", created="Tue, 11 Jul 2006 09:52:28 -0500 (GMT-05:00)"] Fixed in eigenchange 7103 - char now defaults to char(1), so cast('foo' as char) now gives:

0: jdbc:farrago:> values cast('foo' as char);
+---------+
| EXPR$0 |
+---------+
| f |
+---------+
1 row selected (0.922 seconds)