You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What is the bug?
Change type to text in Power BI is not working, an error is shown.
How can one reproduce the bug?
Steps to reproduce the behavior:
Create an empty index
PUT /test
Add a document with a number column
POST /test/_doc?refresh=true
{
"column1": 1
}
Use Power BI with OpenSearch data source connector
Connect to OpenSearch
Select "test" table/index
Click on "Transform Data" button, then "Import" to open Power Query Editor
Right click on column1, select Change Type -> Text
Click "Close & Apply"
An error dialog pops up:
OLE DB or ODBC error: [DataSource.Error] ODBC: ERROR [42000] [OpenSearch][SQL ODBC Driver][SQL Plugin] Invalid SQL query: Unsupported cast type keyword.
What is the expected behavior?
No error dialog, data type is just changed.
What is your host/environment?
OS: Windows
Version 2.11.1.0
Plugins SQL
Do you have any screenshots?
No
Do you have any additional context?
The OpenSearch Power BI connector reports its SQL conformance level as INTERMEDIATE:
...
specificFunction
: CASE expression caseFuncAlternative+ (ELSE elseArg = functionArg)? END # caseFunctionCall
| CASE caseFuncAlternative+ (ELSE elseArg = functionArg)? END # caseFunctionCall
| CAST '(' expression AS convertedDataType ')' # dataTypeFunctionCall
;
...
convertedDataType
: typeName = DATE
| typeName = TIME
| typeName = TIMESTAMP
| typeName = INT
| typeName = INTEGER
| typeName = DOUBLE
| typeName = LONG
| typeName = FLOAT
| typeName = STRING
| typeName = BOOLEAN
;
So it looks like there is an inconsistency in the documented OpenSearch SQL types, the types reported by the ODBC drivers SQLGetTypeInfo and the SQL parser.
Adding keyword support here and in OpenSearchSQLLexer.g4, Cast.java seems to fix the issue, but might not be the best approach as there seems to be already some discussions about types, following the issues linked below.
Related issues that I found, but not quite the same:
What is the bug?
Change type to text in Power BI is not working, an error is shown.
How can one reproduce the bug?
Steps to reproduce the behavior:
PUT /test
POST /test/_doc?refresh=true
{
"column1": 1
}
An error dialog pops up:
OLE DB or ODBC error: [DataSource.Error] ODBC: ERROR [42000] [OpenSearch][SQL ODBC Driver][SQL Plugin] Invalid SQL query: Unsupported cast type keyword.
What is the expected behavior?
No error dialog, data type is just changed.
What is your host/environment?
Do you have any screenshots?
No
Do you have any additional context?
The OpenSearch Power BI connector reports its SQL conformance level as INTERMEDIATE:
https://github.com/opensearch-project/sql-odbc/blob/main/bi-connectors/PowerBIConnector/src/OpenSearchProject.pq#L88C1-L91C12
Looks like this (also) means that the CAST operator is supported:
https://learn.microsoft.com/en-us/sql/odbc/reference/appendixes/sql-92-cast-function?view=sql-server-ver16
SQLGetTypeInfo of the OpenSearch ODBC driver returns the supported types like so (from enabled tracing, snipped):
As far as I understood the table in:
https://opensearch.org/docs/latest/search-plugins/sql/datatypes/
That should be a subset of the "OpenSearach SQL Type" column. That would be fine.
So it looks like when Power BI tries to convert to "text":
It tries to find the best match in the supported types (from top to bottom and via additional attributes) and picks "keyword" (DATA_TYPE -9 is be SQL_WVARCHAR).
See Comments section in: https://learn.microsoft.com/en-us/sql/odbc/reference/syntax/sqlgettypeinfo-function?view=sql-server-ver16
CAST is supported, so it folds the query to:
But
keyword
is not recognized by the SQL parser, just the following:https://github.com/opensearch-project/sql/blob/main/sql/src/main/antlr/OpenSearchSQLParser.g4#L452
So it looks like there is an inconsistency in the documented OpenSearch SQL types, the types reported by the ODBC drivers SQLGetTypeInfo and the SQL parser.
Adding
keyword
support here and inOpenSearchSQLLexer.g4
,Cast.java
seems to fix the issue, but might not be the best approach as there seems to be already some discussions about types, following the issues linked below.Related issues that I found, but not quite the same:
CAST ( ... AS DATETIME)
#853Remark:
Using the plain ODBC Power BI data source connector works fine as no query folding happens (no SQL92 intermediate support).
The text was updated successfully, but these errors were encountered: