You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@metamodel.apache.org by "Kasper Sørensen (JIRA)" <ji...@apache.org> on 2017/03/12 21:57:04 UTC
[jira] [Updated] (METAMODEL-1137) Handle SQL server "variant" data
type by casting to varchar
[ https://issues.apache.org/jira/browse/METAMODEL-1137?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Kasper Sørensen updated METAMODEL-1137:
---------------------------------------
Description:
When I am trying to run the below query:
{code}
SELECT ct."A" FROM dbo."IMAGE_TABLE1" ct
{code}
using MetaModel, it's throwing an exception:
{code}
org.apache.metamodel.MetaModelException: Could not execute query: The "variant" data type is not supported.
{code}
I completely understand that the SQL Server sqlvariant data type is not currently supported by the JDBC driver. If a query is used to retrieve data from a table that contains a column of the sqlvariant data type, an exception will occur.
But when I am casting the "sqlvariant" column to "varchar(30)" in the query then it ran successfully using jTDS ( SQL Server and Sybase JDBC driver).
Here is the (native) query that ran successfully:
{code}
SELECT CAST(A as varchar(30)) from IMAGE_TABLE1
{code}
The same I am expecting from Apache Meta model but Apache Meta model throwing a below exception:
{code}
org.apache.metamodel.query.parser.QueryParserException: Not capable of parsing SELECT token: CAST(A
at org.apache.metamodel.query.parser.SelectItemParser.parse(SelectItemParser.java:68)
at org.apache.metamodel.query.parser.QueryPartParser.parseItem(QueryPartParser.java:122)
at org.apache.metamodel.query.parser.QueryPartParser.parse(QueryPartParser.java:93)
at org.apache.metamodel.query.parser.QueryParser.parseSelectClause(QueryParser.java:160)
at org.apache.metamodel.query.parser.QueryParser.parse(QueryParser.java:95)
at org.apache.metamodel.AbstractDataContext.parseQuery(AbstractDataContext.java:164)
at org.apache.metamodel.AbstractDataContext.executeQuery(AbstractDataContext.java:188)
at org.apache.metamodel.DataContextFactoryTest.testSQLVarient(DataContextFactoryTest.java:69)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at junit.framework.TestCase.runTest(TestCase.java:176)
at junit.framework.TestCase.runBare(TestCase.java:141)
at junit.framework.TestResult$1.protect(TestResult.java:122)
at junit.framework.TestResult.runProtected(TestResult.java:142)
at junit.framework.TestResult.run(TestResult.java:125)
at junit.framework.TestCase.run(TestCase.java:129)
at junit.framework.TestSuite.runTest(TestSuite.java:255)
at junit.framework.TestSuite.run(TestSuite.java:250)
at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:84)
at org.junit.runner.JUnitCore.run(JUnitCore.java:160)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:51)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:237)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
{code}
was:
When I am trying to run the below query:
SELECT ct."A" FROM dbo."IMAGE_TABLE1" ct
using meta-model, it's throwing an exception:
org.apache.metamodel.MetaModelException: Could not execute query: The "variant" data type is not supported.
I completely understand that the SQL Server sqlvariant data type is not currently supported by the JDBC driver. If a query is used to retrieve data from a table that contains a column of the sqlvariant data type, an exception will occur.
But when I am casting the "sqlvariant" column to "varchar(30)" in the query then it ran successfully using jTDS ( SQL Server and Sybase JDBC driver).
Here is the query that ran successfully:
SELECT CAST(A as varchar(30)) from IMAGE_TABLE1
The same I am expecting from Apache Meta model but Apache Meta model throwing a below exception:
org.apache.metamodel.query.parser.QueryParserException: Not capable of parsing SELECT token: CAST(A
at org.apache.metamodel.query.parser.SelectItemParser.parse(SelectItemParser.java:68)
at org.apache.metamodel.query.parser.QueryPartParser.parseItem(QueryPartParser.java:122)
at org.apache.metamodel.query.parser.QueryPartParser.parse(QueryPartParser.java:93)
at org.apache.metamodel.query.parser.QueryParser.parseSelectClause(QueryParser.java:160)
at org.apache.metamodel.query.parser.QueryParser.parse(QueryParser.java:95)
at org.apache.metamodel.AbstractDataContext.parseQuery(AbstractDataContext.java:164)
at org.apache.metamodel.AbstractDataContext.executeQuery(AbstractDataContext.java:188)
at org.apache.metamodel.DataContextFactoryTest.testSQLVarient(DataContextFactoryTest.java:69)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at junit.framework.TestCase.runTest(TestCase.java:176)
at junit.framework.TestCase.runBare(TestCase.java:141)
at junit.framework.TestResult$1.protect(TestResult.java:122)
at junit.framework.TestResult.runProtected(TestResult.java:142)
at junit.framework.TestResult.run(TestResult.java:125)
at junit.framework.TestCase.run(TestCase.java:129)
at junit.framework.TestSuite.runTest(TestSuite.java:255)
at junit.framework.TestSuite.run(TestSuite.java:250)
at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:84)
at org.junit.runner.JUnitCore.run(JUnitCore.java:160)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:51)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:237)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
Issue Type: New Feature (was: Bug)
Summary: Handle SQL server "variant" data type by casting to varchar (was: could not execute query: The "variant" data type is not supported)
> Handle SQL server "variant" data type by casting to varchar
> -----------------------------------------------------------
>
> Key: METAMODEL-1137
> URL: https://issues.apache.org/jira/browse/METAMODEL-1137
> Project: Apache MetaModel
> Issue Type: New Feature
> Affects Versions: 4.5.4
> Environment: Windows & Linux
> Reporter: ASHISH PANCHOLI
> Labels: java, jdbc, jtds, sql_variant, sqlserver, variant
> Attachments: image (1).png
>
>
> When I am trying to run the below query:
> {code}
> SELECT ct."A" FROM dbo."IMAGE_TABLE1" ct
> {code}
> using MetaModel, it's throwing an exception:
> {code}
> org.apache.metamodel.MetaModelException: Could not execute query: The "variant" data type is not supported.
> {code}
> I completely understand that the SQL Server sqlvariant data type is not currently supported by the JDBC driver. If a query is used to retrieve data from a table that contains a column of the sqlvariant data type, an exception will occur.
> But when I am casting the "sqlvariant" column to "varchar(30)" in the query then it ran successfully using jTDS ( SQL Server and Sybase JDBC driver).
> Here is the (native) query that ran successfully:
> {code}
> SELECT CAST(A as varchar(30)) from IMAGE_TABLE1
> {code}
> The same I am expecting from Apache Meta model but Apache Meta model throwing a below exception:
> {code}
> org.apache.metamodel.query.parser.QueryParserException: Not capable of parsing SELECT token: CAST(A
> at org.apache.metamodel.query.parser.SelectItemParser.parse(SelectItemParser.java:68)
> at org.apache.metamodel.query.parser.QueryPartParser.parseItem(QueryPartParser.java:122)
> at org.apache.metamodel.query.parser.QueryPartParser.parse(QueryPartParser.java:93)
> at org.apache.metamodel.query.parser.QueryParser.parseSelectClause(QueryParser.java:160)
> at org.apache.metamodel.query.parser.QueryParser.parse(QueryParser.java:95)
> at org.apache.metamodel.AbstractDataContext.parseQuery(AbstractDataContext.java:164)
> at org.apache.metamodel.AbstractDataContext.executeQuery(AbstractDataContext.java:188)
> at org.apache.metamodel.DataContextFactoryTest.testSQLVarient(DataContextFactoryTest.java:69)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
> at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> at java.lang.reflect.Method.invoke(Method.java:498)
> at junit.framework.TestCase.runTest(TestCase.java:176)
> at junit.framework.TestCase.runBare(TestCase.java:141)
> at junit.framework.TestResult$1.protect(TestResult.java:122)
> at junit.framework.TestResult.runProtected(TestResult.java:142)
> at junit.framework.TestResult.run(TestResult.java:125)
> at junit.framework.TestCase.run(TestCase.java:129)
> at junit.framework.TestSuite.runTest(TestSuite.java:255)
> at junit.framework.TestSuite.run(TestSuite.java:250)
> at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:84)
> at org.junit.runner.JUnitCore.run(JUnitCore.java:160)
> at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
> at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:51)
> at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:237)
> at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
> {code}
--
This message was sent by Atlassian JIRA
(v6.3.15#6346)