-
1. Re: How to create pushdown function for DIGSTRING using ("teiid_rel:native-query" '$1') in VDB ddl xml file?
shawkins Mar 7, 2018 7:27 PM (in response to thiru28)Have you repeated what was successful from Unable to get result on querying piavg or pitotal or pimax views of Pi server via Teiid ?
You would update the DDL section to include an additional function:
CREATE FOREIGN FUNCTION TIMEINTERVAL (arg1 string) RETURNS timestamp OPTIONS ("teiid_rel:native-query" '$1');
CREATE FOREIGN FUNCTION DIGSTRING (arg1 integer) RETURNS string;
You do not need to include an option clause as you want the function to just render in the default way in the source query.
-
2. Re: How to create pushdown function for DIGSTRING using ("teiid_rel:native-query" '$1') in VDB ddl xml file?
thiru28 Mar 7, 2018 8:12 PM (in response to shawkins)<metadata type="NATIVE"/>
<metadata type="DDL">
<![CDATA[
CREATE FOREIGN FUNCTION DIGSTRING(arg1 integer) RETURNS STRING;
]]>
</metadata>
In Squirrel using Teiid JDBC,
SELECT PI.Tag, PI."Time", PI.Value ,DIGSTRING(convert(PI.Value,integer)))
FROM "piarchive"."picomp2" PI
WHERE
PI.tag = 'BA:ACTIVE.1' AND
PI.time BETWEEN '2018-02-25' AND '2018-03-01'
I got an error below,
Error: Remote org.teiid.api.exception.query.QueryParserException: TEIID31100 Parsing error: Encountered "integer))[*])[*] FROM \"piarchive\".\"picomp2\"" at line 1, column 73.
Was expecting: <EOF> | "and" | "as" | "between" | "except" | "fetch" | "filter" | "from" | "in" | "intersect" ...
SQLState: 50000
ErrorCode: 0
-
3. Re: How to create pushdown function for DIGSTRING using ("teiid_rel:native-query" '$1') in VDB ddl xml file?
shawkins Mar 7, 2018 8:49 PM (in response to thiru28)The message is complaining about an extra closing paren ) - you should have DIGSTRING(convert(PI.Value,integer))
-
4. Re: How to create pushdown function for DIGSTRING using ("teiid_rel:native-query" '$1') in VDB ddl xml file?
thiru28 Mar 7, 2018 9:03 PM (in response to shawkins)Error: TEIID30258 Remote org.teiid.api.exception.query.QueryPlannerException: TEIID30258 Expression(s) DIGSTRING(convert(PI."value", integer)) cannot be pushed to source.
SQLState: 50000
ErrorCode: 30258
-
5. Re: How to create pushdown function for DIGSTRING using ("teiid_rel:native-query" '$1') in VDB ddl xml file?
sahithi.r Mar 8, 2018 6:09 AM (in response to shawkins)SELECT convert(PI.Value , integer)
,DIGSTRING(-65536), DIGSTRING(-65537) FROM "piarchive"."picomp2" PI is working.
But including DIGSTRING(cast(PI.Value as integer)) in select is throwing the error.
Error: TEIID30258 Remote org.teiid.api.exception.query.QueryPlannerException: TEIID30258 Expression(s) DIGSTRING(convert(PI."value", integer)) cannot be pushed to source.
SQLState: 50000
ErrorCode: 30258
Please suggest a solution .
Thanks,
Sahithi
-
6. Re: How to create pushdown function for DIGSTRING using ("teiid_rel:native-query" '$1') in VDB ddl xml file?
shawkins Mar 8, 2018 7:30 AM (in response to sahithi.r)That is probably implying that the conversion of value to integer is not supported, thus the function as whole cannot be pushed. You can confirm that looking at the planning debug log. What is the Teiid type for the value column and what version of Teiid are you using?
-
7. Re: How to create pushdown function for DIGSTRING using ("teiid_rel:native-query" '$1') in VDB ddl xml file?
cm.kumar Mar 8, 2018 9:33 AM (in response to shawkins)Teiid type for "value" column is 'object' and teiid version is 9.1.1.
Actually sending the value directly returns the result like DIGSTRING(-65536) but DIGSTRING(cast("value" as integer)) is not getting through. Even forming a sub query, making the field explicitly as integer did not help. But if the data type from PI server itself is integer, it converts. Like there is one column "status", which is of type integer. so doing DIGSTRING(status), gets results.
-
8. Re: How to create pushdown function for DIGSTRING using ("teiid_rel:native-query" '$1') in VDB ddl xml file?
shawkins Mar 8, 2018 9:47 AM (in response to cm.kumar)> Actually sending the value directly returns the result like DIGSTRING(-65536) but DIGSTRING(cast("value" as integer)) is not getting through
Yes, it is the conversion that is inhibiting pushdown. Generally the conversion from the object type is not pushed down. What is the actual source type of value?
If for whatever reason you need it to be an object type, a workaround is to change the function signature:
CREATE FOREIGN FUNCTION DIGSTRING (arg1 object) RETURNS string;
-
9. Re: How to create pushdown function for DIGSTRING using ("teiid_rel:native-query" '$1') in VDB ddl xml file?
sahithi.r Mar 8, 2018 10:41 AM (in response to shawkins)Tried changing the function signature too.but no luck.
still facing the same issue.
-
10. Re: How to create pushdown function for DIGSTRING using ("teiid_rel:native-query" '$1') in VDB ddl xml file?
shawkins Mar 8, 2018 11:04 AM (in response to sahithi.r)You should always check the planning debug log in instances like this as it should provide an exact message.
You'll need to post the vdb before I can make any more suggestions. Also can you provide the source type of value?
-
11. Re: How to create pushdown function for DIGSTRING using ("teiid_rel:native-query" '$1') in VDB ddl xml file?
thiru28 Mar 8, 2018 2:25 PM (in response to shawkins)Here below query getting an error,
SELECT PI.Tag, PI."Time",PI.Value ,DIGSTRING(CONVERT(PI.Value,INTEGER)) STATUS
FROM "piarchive"."picomp2" PI
WHERE
PI.tag = 'BA:ACTIVE.1' AND
PI.time BETWEEN '2018-02-28' AND '2018-03-01'
AND PI.Value IS NOT NULL
I am able to get the result of digital state from "picomp" instead of "picomp2",
SELECT PI.Tag, PI."Time",DIGSTRING(CONVERT(PI.status,INTEGER)) STATUS
FROM "piarchive"."picomp" PI
WHERE
PI.tag = 'BA:ACTIVE.1' AND
PI.time BETWEEN '2018-02-28' AND '2018-03-01'
AND PI.status IS NOT NULL
-
12. Re: How to create pushdown function for DIGSTRING using ("teiid_rel:native-query" '$1') in VDB ddl xml file?
ragava28 Aug 24, 2018 7:07 PM (in response to shawkins)Hi Steven ,
I am also having the same issue.
The query which i am trying is below, error message is "TEIID30258 Expression(s) DIGSTRING(CONVERT(PI."value", INTEGER)) cannot be pushed to source."
SELECT
PI.tag AS TAG,
CAST(PI."Time" as timestamp) AS MEAS_DATE,
CAST(PI."value" as double) AS MEAS_VALUE,
DIGSTRING(CONVERT(PI."value",INTEGER)) AS MEAS_VALUE_TEXT,
DIGSTRING(CONVERT(PI.status,INTEGER)) AS STATUS_VALUE_TEXT
FROM
PI.PIArchive.pisnapshot PI
I also created a function which excepts object. but this also didn't work , as in PI server we don't have any function with this signature. Pi only recognizes argument with integer as input.
CREATE FOREIGN FUNCTION DIGSTRING (arg1 object) RETURNS string;
Below are the details of the value column when accessed from PI native JDBC drive & Teiid . attached the screen shots also.
Native Jdbc driver : Variant (java.lang.Object)
Teiid : object (java.lang.Object)
I have attached the trimmed version of the vdb also for reference.
Can you please help on this issue.
-
SampleVDB.vdb.zip 1.3 KB
-
NativeJDBC.png 9.7 KB
-
Teiid.png 23.4 KB
-
teiidlog.txt.zip 1.0 KB
-
-
13. Re: How to create pushdown function for DIGSTRING using ("teiid_rel:native-query" '$1') in VDB ddl xml file?
shawkins Aug 26, 2018 1:00 PM (in response to ragava28)Raghu,
The base translator logic assumes that conversion from object is not supported. It looks like pi has variant support, so this should be allowed - can you log an issue?
> as in PI server we don't have any function with this signature. Pi only recognizes argument with integer as input.
If an explicit cast is needed in the Pi SQL, you can change/add to your teiid ddl as a workaround:
CREATE FOREIGN FUNCTION DIGSTRING (arg1 object) RETURNS string OPTIONS ("teiid_rel:native-query" 'DIGSTRING(cast($1 as Int32)')
-
14. Re: How to create pushdown function for DIGSTRING using ("teiid_rel:native-query" '$1') in VDB ddl xml file?
shawkins Aug 28, 2018 9:29 AM (in response to shawkins)> can you log an issue?
I inadvertently already made the change, so I went ahead and captured this as: [TEIID-5458] Allow pi to convert from object/variant type - JBoss Issue Tracker