Back to home page

OSCL-LXR

 
 

    


0001 --
0002 --   Licensed to the Apache Software Foundation (ASF) under one or more
0003 --   contributor license agreements.  See the NOTICE file distributed with
0004 --   this work for additional information regarding copyright ownership.
0005 --   The ASF licenses this file to You under the Apache License, Version 2.0
0006 --   (the "License"); you may not use this file except in compliance with
0007 --   the License.  You may obtain a copy of the License at
0008 --
0009 --      http://www.apache.org/licenses/LICENSE-2.0
0010 --
0011 --   Unless required by applicable law or agreed to in writing, software
0012 --   distributed under the License is distributed on an "AS IS" BASIS,
0013 --   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
0014 --   See the License for the specific language governing permissions and
0015 --   limitations under the License.
0016 --
0017 
0018 CREATE TEMPORARY VIEW t AS SELECT 'aa' as a;
0019 
0020 -- casting to data types which are unable to represent the string input returns NULL
0021 select cast(a as byte) from t;
0022 select cast(a as short) from t;
0023 select cast(a as int) from t;
0024 select cast(a as long) from t;
0025 select cast(a as float) from t;
0026 select cast(a as double) from t;
0027 select cast(a as decimal) from t;
0028 select cast(a as boolean) from t;
0029 select cast(a as timestamp) from t;
0030 select cast(a as date) from t;
0031 -- casting to binary works correctly
0032 select cast(a as binary) from t;
0033 -- casting to array, struct or map throws exception
0034 select cast(a as array<string>) from t;
0035 select cast(a as struct<s:string>) from t;
0036 select cast(a as map<string, string>) from t;
0037 
0038 -- all timestamp/date expressions return NULL if bad input strings are provided
0039 select to_timestamp(a) from t;
0040 select to_timestamp('2018-01-01', a) from t;
0041 select to_unix_timestamp(a) from t;
0042 select to_unix_timestamp('2018-01-01', a) from t;
0043 select unix_timestamp(a) from t;
0044 select unix_timestamp('2018-01-01', a) from t;
0045 select from_unixtime(a) from t;
0046 select from_unixtime('2018-01-01', a) from t;
0047 select next_day(a, 'MO') from t;
0048 select next_day('2018-01-01', a) from t;
0049 select trunc(a, 'MM') from t;
0050 select trunc('2018-01-01', a) from t;
0051 
0052 -- some functions return NULL if bad input is provided
0053 select unhex('-123');
0054 select sha2(a, a) from t;
0055 select get_json_object(a, a) from t;
0056 select json_tuple(a, a) from t;
0057 select from_json(a, 'a INT') from t;