📄 function.query
字号:
######################### These tests are desined to test the CQL Functions. Each query statement# in this file executes on a set of instances of CQL_TestPropertytypes.# The test program should be invoked like this:# cqlcli $PEGASUS_ROOT/src/Pegasus/CQL/tests/Queries/Function.query -test 1 -className CQL_TestPropertytypes# The output of this should match the output of Function.query.resgood found in the .../tests/Queries directory.###################################### Datetime to microsecond#############select * from CQL_TestPropertyTypes where 63259462585000000 = DATETIMETOMICROSECOND(PropertyDateTime)select * from CQL_TestPropertyTypes where 1066666660424123456 = DATETIMETOMICROSECOND(PropertyInterval)# Errorsselect * from CQL_TestPropertyTypes where 464235 = DATETIMETOMICROSECOND()select * from CQL_TestPropertyTypes where 464235 = DATETIMETOMICROSECOND(2344)############# Uppercase############select * from CQL_TestPropertyTypes where PropertyString = UPPERCASE('Bert Rules')select * from CQL_TestPropertyTypes where PropertyString = UPPERCASE('')# Errors in uppercaseselect * from CQL_TestPropertyTypes where PropertyString = UPPERCASE('Bert Rules', 'Not really')select * from CQL_TestPropertyTypes where PropertyString = UPPERCASE()select * from CQL_TestPropertyTypes where PropertyString = UPPERCASE(PropertyReal32)select * from CQL_TestPropertyTypes where PropertyString = UPPERCASE(-12.3434e-1)############# String to various number formats############# A few tests for a string property to number conversionselect * from CQL_TestPropertyTypes where STRINGTOUINT(PropertyStringUint) = 347select * from CQL_TestPropertyTypes where STRINGTOSINT(PropertyStringSint) = -743select * from CQL_TestPropertyTypes where STRINGTOREAL(PropertyStringReal) = 98.67# Test True String to Number conversionsselect * from CQL_TestPropertyTypes where PropertyUint32 = stringtouint('32.32')select * from CQL_TestPropertyTypes where PropertyUint32 = stringtouint('32.72')select * from CQL_TestPropertyTypes where PropertyUint32 = stringtouint('32.0')select * from CQL_TestPropertyTypes where PropertyUint32 = stringtouint('0x01a9b')select * from CQL_TestPropertyTypes where PropertySint32 = stringtosint('-32.32')select * from CQL_TestPropertyTypes where PropertySint32 = stringtosint('-32.0')select * from CQL_TestPropertyTypes where PropertySint32 = stringtosint('-32.72')select * from CQL_TestPropertyTypes where PropertySint32 = stringtosint('-0x01a9b')select * from CQL_TestPropertyTypes where PropertyReal32 = STRINGTOREAL('-32')select * from CQL_TestPropertyTypes where PropertyReal32 = STRINGTOREAL('-32.0')select * from CQL_TestPropertyTypes where PropertyReal32 = STRINGTOREAL('-.32e2')select * from CQL_TestPropertyTypes where PropertyReal32 = STRINGTOREAL('-0.32E+02')select * from CQL_TestPropertyTypes where PropertyReal32 = STRINGTOREAL('-0x20')select * from CQL_TestPropertyTypes where PropertyReal32 = STRINGTOREAL('-00100000b')select * from CQL_TestPropertyTypes where PropertyReal32 = STRINGTOREAL('-100000B')select * from CQL_TestPropertyTypes where PropertyReal64 = STRINGTONUMERIC('+64')select * from CQL_TestPropertyTypes where PropertyReal64 = STRINGTONUMERIC('+64.0')select * from CQL_TestPropertyTypes where PropertyReal64 = STRINGTONUMERIC('+0x40')select * from CQL_TestPropertyTypes where PropertyReal64 = STRINGTONUMERIC('+1000000b')select * from CQL_TestPropertyTypes where PropertyReal64 = STRINGTONUMERIC('64')select * from CQL_TestPropertyTypes where PropertyReal64 = STRINGTONUMERIC('64.0')select * from CQL_TestPropertyTypes where PropertyReal64 = STRINGTONUMERIC('0x40')select * from CQL_TestPropertyTypes where PropertyReal64 = STRINGTONUMERIC('1000000b')select * from CQL_TestPropertyTypes where PropertyReal64 = STRINGTONUMERIC('64.64')select * from CQL_TestPropertyTypes where PropertyReal64 = STRINGTONUMERIC('646.4e-01')select * from CQL_TestPropertyTypes where PropertyReal64 = STRINGTONUMERIC('6.464E+01')select * from CQL_TestPropertyTypes where PropertyReal64 = STRINGTONUMERIC('.6464e2')select * from CQL_TestPropertyTypes where PropertyReal64 = STRINGTONUMERIC('0.6464e2')select * from CQL_TestPropertyTypes where PropertyReal64 = STRINGTOREAL('+64.64')# This comparison wil fail due to precision loss in the Real32select * from CQL_TestPropertyTypes where PropertyReal32 = STRINGTOREAL('32.2')# Test valid boundaries all should be true for string to number conversionselect * from CQL_TestPropertyTypes where PropertyUint8 = STRINGTOUINT('+255')select * from CQL_TestPropertyTypes where PropertyUint8 = STRINGTOUINT('+0xFF')select * from CQL_TestPropertyTypes where PropertyUint8 = STRINGTOUINT('+11111111b')select * from CQL_TestPropertyTypes where PropertyUint64 = STRINGTOUINT('+18446744073709551615')select * from CQL_TestPropertyTypes where PropertyUint64 = STRINGTOUINT('+0xFFFFffffFFFFffff')select * from CQL_TestPropertyTypes where PropertyUint64 = STRINGTOUINT('+1111111111111111111111111111111111111111111111111111111111111111B')select * from CQL_TestPropertyTypes where PropertySint8Lower = STRINGTOSINT('-128')select * from CQL_TestPropertyTypes where PropertySint8Lower = STRINGTOSINT('-0x80')select * from CQL_TestPropertyTypes where PropertySint8Lower = STRINGTOSINT('-10000000b')select * from CQL_TestPropertyTypes where PropertySint8Upper = STRINGTOSINT('127')select * from CQL_TestPropertyTypes where PropertySint8Upper = STRINGTOSINT('0x7f')select * from CQL_TestPropertyTypes where PropertySint8Upper = STRINGTOSINT('01111111B')select * from CQL_TestPropertyTypes where PropertySint64Lower = STRINGTOSINT('-9223372036854775808')select * from CQL_TestPropertyTypes where PropertySint64Lower = STRINGTOSINT('-0x8000000000000000')select * from CQL_TestPropertyTypes where PropertySint64Lower = STRINGTOSINT('-1000000000000000000000000000000000000000000000000000000000000000b')select * from CQL_TestPropertyTypes where PropertySint64Upper = STRINGTOSINT('9223372036854775807')select * from CQL_TestPropertyTypes where PropertySint64Upper = STRINGTOSINT('0x7fffFFFFffffFFFF')select * from CQL_TestPropertyTypes where PropertySint64Upper = STRINGTOSINT('0111111111111111111111111111111111111111111111111111111111111111B')# Test Various overflows/underflows for string to number(queries should throw errors)select * from CQL_TestPropertyTypes where PropertyUint64 = STRINGTOUINT('18446744073709551616')select * from CQL_TestPropertyTypes where PropertyUint64 = STRINGTOUINT('0x10000000000000000')select * from CQL_TestPropertyTypes where PropertyUint64 = STRINGTOUINT('10000000000000000000000000000000000000000000000000000000000000000B')select * from CQL_TestPropertyTypes where PropertySint64Lower = STRINGTOSINT('-9223372036854775809')select * from CQL_TestPropertyTypes where PropertySint64Lower = STRINGTOSINT('-0x8000000000000001')select * from CQL_TestPropertyTypes where PropertySint64Lower = STRINGTOSINT('-1000000000000000000000000000000000000000000000000000000000000001b')select * from CQL_TestPropertyTypes where CQL_TestPropertyTypes.PropertySint64Upper = STRINGTOSINT('9223372036854775808')select * from CQL_TestPropertyTypes where PropertySint64Upper = STRINGTOSINT('0x8000000000000000')select * from CQL_TestPropertyTypes where PropertySint64Upper = STRINGTOSINT('1000000000000000000000000000000000000000000000000000000000000000B')# Errors in StringToUintselect * from CQL_TestPropertyTypes where PropertyUint64 = STRINGTOUINT('32', '33')select * from CQL_TestPropertyTypes where PropertyUint64 = STRINGTOUINT()select * from CQL_TestPropertyTypes where PropertyUint64 = STRINGTOUINT(33)select * from CQL_TestPropertyTypes where PropertyUint64 = STRINGTOUINT(PropertyUint64)select * from CQL_TestPropertyTypes where PropertyUint64 = STRINGTOUINT('')select * from CQL_TestPropertyTypes where PropertyUint64 = STRINGTOUINT('-27')select * from CQL_TestPropertyTypes where PropertyUint64 = STRINGTOUINT('+a22')select * from CQL_TestPropertyTypes where PropertyUint64 = STRINGTOUINT('a22')select * from CQL_TestPropertyTypes where PropertyUint64 = STRINGTOUINT('0121b')select * from CQL_TestPropertyTypes where PropertyUint64 = STRINGTOUINT('01a1b')select * from CQL_TestPropertyTypes where PropertyUint64 = STRINGTOUINT('0x')select * from CQL_TestPropertyTypes where PropertyUint64 = STRINGTOUINT('0xFG2')select * from CQL_TestPropertyTypes where PropertyUint64 = STRINGTOUINT('02x34')select * from CQL_TestPropertyTypes where PropertyUint32 = stringtouint('0101bb')# Errors in StringToSintselect * from CQL_TestPropertyTypes where PropertySint64 = STRINGTOSINT('-32', '-33')select * from CQL_TestPropertyTypes where PropertySint64 = STRINGTOSINT()select * from CQL_TestPropertyTypes where PropertySint64 = STRINGTOSINT(-33)select * from CQL_TestPropertyTypes where PropertySint64 = STRINGTOSINT(PropertySint64)select * from CQL_TestPropertyTypes where PropertySint64 = STRINGTOSINT('')select * from CQL_TestPropertyTypes where PropertySint64 = STRINGTOSINT('-a22')select * from CQL_TestPropertyTypes where PropertySint64 = STRINGTOSINT('a22')select * from CQL_TestPropertyTypes where PropertySint64 = STRINGTOSINT('-0121b')select * from CQL_TestPropertyTypes where PropertySint64 = STRINGTOSINT('-01a1b')select * from CQL_TestPropertyTypes where PropertySint64 = STRINGTOSINT('-0x')select * from CQL_TestPropertyTypes where PropertySint64 = STRINGTOSINT('-0xFG2')select * from CQL_TestPropertyTypes where PropertySint64 = STRINGTOSINT('-02x34')select * from CQL_TestPropertyTypes where PropertySint32 = stringtosint('-0101bb')# Errors in StringToRealselect * from CQL_TestPropertyTypes where PropertyReal64 = STRINGTOREAL('32.32', '33.33')select * from CQL_TestPropertyTypes where PropertyReal64 = STRINGTOREAL()select * from CQL_TestPropertyTypes where PropertyReal64 = STRINGTOREAL(34.34e-2)select * from CQL_TestPropertyTypes where PropertyReal64 = STRINGTOREAL(35.35E2)select * from CQL_TestPropertyTypes where PropertyReal64 = STRINGTOREAL(PropertyReal64)select * from CQL_TestPropertyTypes where PropertyReal64 = STRINGTOREAL('')select * from CQL_TestPropertyTypes where PropertyReal64 = STRINGTOREAL('32.')select * from CQL_TestPropertyTypes where PropertyReal64 = STRINGTOREAL('3a3.32')select * from CQL_TestPropertyTypes where PropertyReal64 = STRINGTOREAL('32.3a3')select * from CQL_TestPropertyTypes where PropertyReal64 = STRINGTOREAL('32.33E-a2')############## NumericToString
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -