clickhouse-odbc#125 : Make TIMESTAMP alias for DateTime type for allowing CAST(x AS TIMESTAMP)

This commit is contained in:
proller 2018-10-15 18:10:34 +03:00
parent 394b9760f4
commit 0cf72f9b26
3 changed files with 4 additions and 0 deletions

View File

@ -172,6 +172,7 @@ static DataTypePtr create(const ASTPtr & arguments)
void registerDataTypeDateTime(DataTypeFactory & factory) void registerDataTypeDateTime(DataTypeFactory & factory)
{ {
factory.registerDataType("DateTime", create, DataTypeFactory::CaseInsensitive); factory.registerDataType("DateTime", create, DataTypeFactory::CaseInsensitive);
factory.registerAlias("TIMESTAMP", "DateTime", DataTypeFactory::CaseInsensitive);
} }

View File

@ -6,6 +6,7 @@ hello
hello hello
hello hello
hello hello
1970-01-01 00:00:01
CREATE TABLE test.cast ( x UInt8, e Enum8('hello' = 1, 'world' = 2) DEFAULT CAST(x, 'Enum8(\'hello\' = 1, \'world\' = 2)')) ENGINE = MergeTree ORDER BY e SETTINGS index_granularity = 8192 CREATE TABLE test.cast ( x UInt8, e Enum8('hello' = 1, 'world' = 2) DEFAULT CAST(x, 'Enum8(\'hello\' = 1, \'world\' = 2)')) ENGINE = MergeTree ORDER BY e SETTINGS index_granularity = 8192
x UInt8 x UInt8
e Enum8(\'hello\' = 1, \'world\' = 2) DEFAULT CAST(x, \'Enum8(\\\'hello\\\' = 1, \\\'world\\\' = 2)\') e Enum8(\'hello\' = 1, \'world\' = 2) DEFAULT CAST(x, \'Enum8(\\\'hello\\\' = 1, \\\'world\\\' = 2)\')

View File

@ -15,6 +15,8 @@ SELECT cast(1 AS Enum8(
SELECT CAST(1, 'Enum8(\'hello\' = 1,\n\t\'world\' = 2)'); SELECT CAST(1, 'Enum8(\'hello\' = 1,\n\t\'world\' = 2)');
SELECT cast(1, 'Enum8(\'hello\' = 1,\n\t\'world\' = 2)'); SELECT cast(1, 'Enum8(\'hello\' = 1,\n\t\'world\' = 2)');
SELECT toTimeZone(CAST(1 AS TIMESTAMP), 'UTC');
DROP TABLE IF EXISTS test.cast; DROP TABLE IF EXISTS test.cast;
CREATE TABLE test.cast CREATE TABLE test.cast
( (