Skip to content

Commit

Permalink
Type conversion (#318)
Browse files Browse the repository at this point in the history
* Added Tableau Connector to OpenSearch SQL

Signed-off-by: Guian Gumpac <[email protected]>

* Added CEILING and FLOOR functions

Signed-off-by: Guian Gumpac <[email protected]>

* Added IFNULL function

Signed-off-by: Guian Gumpac <[email protected]>

* Added Kyle's fix for ADDDATE and SUBDATE with resulting 00:00:00 being unexpectedly null

Signed-off-by: Guian Gumpac <[email protected]>

* Added MIN and MAX for two string arguments

Signed-off-by: Guian Gumpac <[email protected]>

* Fixed return type for MID function redefenitions, part of AOS-202

Signed-off-by: Yury Fridlyand <[email protected]>

* Added CAST functions to convert to int or string as part of AOS-202

Signed-off-by: Yury Fridlyand <[email protected]>

* Added HEXBINX and HEXBINY functions from the templace without any modifications

Signed-off-by: Yury Fridlyand <[email protected]>

* Fixed cast to use the OSSQL type

Signed-off-by: Yury Fridlyand <[email protected]>

* Added parenthesis to avoid /issues/293

Signed-off-by: Yury Fridlyand <[email protected]>

* Modified Timestamp conversion formula

Signed-off-by: Guian Gumpac <[email protected]>

* Added comment to TimestampType

Signed-off-by: Guian Gumpac <[email protected]>

* Updated Company Name accroding to the customer's request

Signed-off-by: Yury Fridlyand <[email protected]>

* Updated Vendor Name as well

Signed-off-by: Yury Fridlyand <[email protected]>

* Modified the driver to recognize its support for conversion of types

Signed-off-by: Guian Gumpac <[email protected]>

* Removed changes from a different branch

Signed-off-by: Guian Gumpac <[email protected]>

* Removed changes from a different branch

Signed-off-by: Guian Gumpac <[email protected]>

* Made the connector convert keyword columns to string columns

Signed-off-by: Guian Gumpac <[email protected]>

* Modified integration tests to reflect support for conversion types

Signed-off-by: Guian Gumpac <[email protected]>

* Removed connector changes

Signed-off-by: Guian Gumpac <[email protected]>

* Change values to bitmasks

Signed-off-by: Guian Gumpac <[email protected]>

* Removed jdbc changes from previous commits

Signed-off-by: Guian Gumpac <[email protected]>

* Removed jdbc changes from previous commits

Signed-off-by: Guian Gumpac <[email protected]>

* Removed jdbc changes from previous commits

Signed-off-by: Guian Gumpac <[email protected]>

Co-authored-by: Yury Fridlyand <[email protected]>
Co-authored-by: Yury-Fridlyand <[email protected]>
  • Loading branch information
3 people authored Dec 13, 2021
1 parent 4a020db commit 2411dc3
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 14 deletions.
14 changes: 7 additions & 7 deletions sql-odbc/src/IntegrationTests/ITODBCInfo/test_odbc_info.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,20 +208,20 @@ TEST_SQL_GET_INFO_STRING(SQLCatalogName, SQL_CATALOG_NAME, L"N");
// Conversion //
////////////////

TEST_SQL_GET_INFO_UINT_MASK(SQLConvertInteger, SQL_CONVERT_INTEGER, 0);
TEST_SQL_GET_INFO_UINT_MASK(SQLConvertInteger, SQL_CONVERT_INTEGER, SQL_CVT_INTEGER | SQL_CVT_REAL | SQL_CVT_DOUBLE | SQL_CVT_BIT | SQL_CVT_BIGINT | SQL_CVT_WVARCHAR);
TEST_SQL_GET_INFO_UINT_MASK(SQLConvertSmallint, SQL_CONVERT_SMALLINT, 0);
TEST_SQL_GET_INFO_UINT_MASK(SQLConvertTinyint, SQL_CONVERT_TINYINT, 0);
TEST_SQL_GET_INFO_UINT_MASK(SQLConvertBit, SQL_CONVERT_BIT, 0);
TEST_SQL_GET_INFO_UINT_MASK(SQLConvertBit, SQL_CONVERT_BIT, SQL_CVT_INTEGER | SQL_CVT_REAL | SQL_CVT_DOUBLE | SQL_CVT_BIT | SQL_CVT_BIGINT | SQL_CVT_WVARCHAR);
TEST_SQL_GET_INFO_UINT_MASK(SQLConvertVarchar, SQL_CONVERT_VARCHAR, 0);
TEST_SQL_GET_INFO_UINT_MASK(SQLConvertBigint, SQL_CONVERT_BIGINT, 0);
TEST_SQL_GET_INFO_UINT_MASK(SQLConvertBigint, SQL_CONVERT_BIGINT, SQL_CVT_INTEGER | SQL_CVT_REAL | SQL_CVT_DOUBLE | SQL_CVT_BIT | SQL_CVT_BIGINT | SQL_CVT_WVARCHAR);
TEST_SQL_GET_INFO_UINT_MASK(SQLConvertDecimal, SQL_CONVERT_DECIMAL, 0);
TEST_SQL_GET_INFO_UINT_MASK(SQLConvertDouble, SQL_CONVERT_DOUBLE, 0);
TEST_SQL_GET_INFO_UINT_MASK(SQLConvertDouble, SQL_CONVERT_DOUBLE, SQL_CVT_INTEGER | SQL_CVT_REAL | SQL_CVT_DOUBLE | SQL_CVT_BIT | SQL_CVT_BIGINT | SQL_CVT_WVARCHAR);
TEST_SQL_GET_INFO_UINT_MASK(SQLConvertFloat, SQL_CONVERT_FLOAT, 0);
TEST_SQL_GET_INFO_UINT_MASK(SQLConvertNumeric, SQL_CONVERT_NUMERIC, 0);
TEST_SQL_GET_INFO_UINT_MASK(SQLConvertReal, SQL_CONVERT_REAL, 0);
TEST_SQL_GET_INFO_UINT_MASK(SQLConvertReal, SQL_CONVERT_REAL, SQL_CVT_INTEGER | SQL_CVT_REAL | SQL_CVT_DOUBLE | SQL_CVT_BIT | SQL_CVT_BIGINT | SQL_CVT_WVARCHAR);
TEST_SQL_GET_INFO_UINT_MASK(SQLConvertDate, SQL_CONVERT_DATE, 0);
TEST_SQL_GET_INFO_UINT_MASK(SQLConvertTime, SQL_CONVERT_TIME, 0);
TEST_SQL_GET_INFO_UINT_MASK(SQLConvertTimestamp, SQL_CONVERT_TIMESTAMP, 0);
TEST_SQL_GET_INFO_UINT_MASK(SQLConvertTimestamp, SQL_CONVERT_TIMESTAMP, SQL_CVT_TIMESTAMP | SQL_CVT_WVARCHAR);
TEST_SQL_GET_INFO_UINT_MASK(SQLConvertBinary, SQL_CONVERT_BINARY, 0);
TEST_SQL_GET_INFO_UINT_MASK(SQLConvertLongvarbinary, SQL_CONVERT_LONGVARBINARY,
0);
Expand All @@ -231,7 +231,7 @@ TEST_SQL_GET_INFO_UINT_MASK(SQLConvertLongVarchar, SQL_CONVERT_LONGVARCHAR, 0);
TEST_SQL_GET_INFO_UINT_MASK(SQLConvertWChar, SQL_CONVERT_WCHAR, 0);
TEST_SQL_GET_INFO_UINT_MASK(SQLConvertWLongVarchar, SQL_CONVERT_WLONGVARCHAR,
0);
TEST_SQL_GET_INFO_UINT_MASK(SQLConvertWVarchar, SQL_CONVERT_WVARCHAR, 0);
TEST_SQL_GET_INFO_UINT_MASK(SQLConvertWVarchar, SQL_CONVERT_WVARCHAR, SQL_CVT_INTEGER | SQL_CVT_REAL | SQL_CVT_DOUBLE | SQL_CVT_BIGINT | SQL_CVT_WVARCHAR);
TEST_SQL_GET_INFO_UINT_MASK(SQLConvertGuid, SQL_CONVERT_GUID, 0);

//////////////////////
Expand Down
42 changes: 35 additions & 7 deletions sql-odbc/src/sqlodbc/info.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,20 +104,14 @@ RETCODE SQL_API OPENSEARCHAPI_GetInfo(HDBC hdbc, SQLUSMALLINT fInfoType,
break;

case SQL_CONVERT_GUID:
case SQL_CONVERT_INTEGER:
case SQL_CONVERT_SMALLINT:
case SQL_CONVERT_TINYINT:
case SQL_CONVERT_BIT:
case SQL_CONVERT_VARCHAR:
case SQL_CONVERT_BIGINT:
case SQL_CONVERT_DECIMAL:
case SQL_CONVERT_DOUBLE:
case SQL_CONVERT_FLOAT:
case SQL_CONVERT_NUMERIC:
case SQL_CONVERT_REAL:
case SQL_CONVERT_DATE:
case SQL_CONVERT_TIME:
case SQL_CONVERT_TIMESTAMP:
case SQL_CONVERT_BINARY:
case SQL_CONVERT_LONGVARBINARY:
case SQL_CONVERT_VARBINARY: /* ODBC 1.0 */
Expand All @@ -126,12 +120,46 @@ RETCODE SQL_API OPENSEARCHAPI_GetInfo(HDBC hdbc, SQLUSMALLINT fInfoType,
#ifdef UNICODE_SUPPORT
case SQL_CONVERT_WCHAR:
case SQL_CONVERT_WLONGVARCHAR:
case SQL_CONVERT_WVARCHAR:
#endif /* UNICODE_SUPPORT */
len = sizeof(SQLUINTEGER);
value = 0; /* CONVERT is unavailable */
break;

case SQL_CONVERT_INTEGER: /* ODBC 1.0 */
len = sizeof(SQLUINTEGER);
value = SQL_CVT_INTEGER | SQL_CVT_BIT | SQL_CVT_WVARCHAR | SQL_CVT_DOUBLE | SQL_CVT_BIGINT | SQL_CVT_REAL;
break;

case SQL_CONVERT_BIT: /* ODBC 1.0 */
len = sizeof(SQLUINTEGER);
value = SQL_CVT_BIT | SQL_CVT_INTEGER | SQL_CVT_WVARCHAR | SQL_CVT_DOUBLE | SQL_CVT_BIGINT | SQL_CVT_REAL;
break;

case SQL_CONVERT_WVARCHAR: /* ODBC 1.0 */
len = sizeof(SQLUINTEGER);
value = SQL_CVT_WVARCHAR | SQL_CVT_INTEGER | SQL_CVT_DOUBLE | SQL_CVT_BIGINT | SQL_CVT_REAL;
break;

case SQL_CONVERT_DOUBLE: /* ODBC 1.0 */
len = sizeof(SQLUINTEGER);
value = SQL_CVT_DOUBLE | SQL_CVT_INTEGER | SQL_CVT_BIT | SQL_CVT_WVARCHAR | SQL_CVT_BIGINT | SQL_CVT_REAL;
break;

case SQL_CONVERT_BIGINT: /* ODBC 1.0 */
len = sizeof(SQLUINTEGER);
value = SQL_CVT_BIGINT | SQL_CVT_INTEGER | SQL_CVT_BIT | SQL_CVT_WVARCHAR | SQL_CVT_DOUBLE | SQL_CVT_REAL;
break;

case SQL_CONVERT_REAL: /* ODBC 1.0 */
len = sizeof(SQLUINTEGER);
value = SQL_CVT_REAL | SQL_CVT_INTEGER | SQL_CVT_BIT | SQL_CVT_WVARCHAR | SQL_CVT_DOUBLE | SQL_CVT_BIGINT;
break;

case SQL_CONVERT_TIMESTAMP: /* ODBC 1.0 */
len = sizeof(SQLUINTEGER);
value = SQL_CVT_TIMESTAMP | SQL_CVT_WVARCHAR;
break;

case SQL_CONVERT_FUNCTIONS: /* ODBC 1.0 */
len = sizeof(SQLUINTEGER);
value = SQL_FN_CVT_CAST;
Expand Down

0 comments on commit 2411dc3

Please sign in to comment.