Merge pull request #3774 from yandex/missing-sql-compatibility-functions

Some function name aliases and case insensitivity for SQL compatibility
This commit is contained in:
alexey-milovidov 2018-12-07 02:36:27 +03:00 committed by GitHub
commit 8ad92ad94f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 20 additions and 4 deletions

View File

@ -1088,5 +1088,7 @@ void registerFunctionsStringSearch(FunctionFactory & factory)
factory.registerFunction<FunctionLike>();
factory.registerFunction<FunctionNotLike>();
factory.registerFunction<FunctionExtract>();
factory.registerAlias("locate", NamePosition::name, FunctionFactory::CaseInsensitive);
factory.registerAlias("replace", NameReplaceAll::name, FunctionFactory::CaseInsensitive);
}
}

View File

@ -936,7 +936,7 @@ public:
void registerFunctionIf(FunctionFactory & factory)
{
factory.registerFunction<FunctionIf>();
factory.registerFunction<FunctionIf>(FunctionFactory::CaseInsensitive);
}
}

View File

@ -16,7 +16,7 @@ using FunctionLower = FunctionStringToString<LowerUpperImpl<'A', 'Z'>, NameLower
void registerFunctionLower(FunctionFactory & factory)
{
factory.registerFunction<FunctionLower>(FunctionFactory::CaseInsensitive);
factory.registerAlias("lcase", "lower", FunctionFactory::CaseInsensitive);
factory.registerAlias("lcase", NameLower::name, FunctionFactory::CaseInsensitive);
}
}

View File

@ -166,7 +166,9 @@ public:
void registerFunctionSubstring(FunctionFactory & factory)
{
factory.registerFunction<FunctionSubstring>();
factory.registerFunction<FunctionSubstring>(FunctionFactory::CaseInsensitive);
factory.registerAlias("substr", FunctionSubstring::name, FunctionFactory::CaseInsensitive);
factory.registerAlias("mid", FunctionSubstring::name, FunctionFactory::CaseInsensitive); /// from MySQL dialect
}
}

View File

@ -16,7 +16,7 @@ using FunctionUpper = FunctionStringToString<LowerUpperImpl<'a', 'z'>, NameUpper
void registerFunctionUpper(FunctionFactory & factory)
{
factory.registerFunction<FunctionUpper>(FunctionFactory::CaseInsensitive);
factory.registerAlias("ucase", "upper", FunctionFactory::CaseInsensitive);
factory.registerAlias("ucase", FunctionUpper::name, FunctionFactory::CaseInsensitive);
}
}

View File

@ -2,3 +2,9 @@ foo
FOO
foo
FOO
baz
2
fo
oo
o
1

View File

@ -4,3 +4,9 @@ select lcase('FOO');
select ucase('foo');
select LOWER('Foo');
select UPPER('Foo');
select REPLACE('bar', 'r', 'z');
select Locate('foo', 'o');
select SUBSTRING('foo', 1, 2);
select Substr('foo', 2);
select mid('foo', 3);
select IF(3>2, 1, 0);