[JBoss JIRA] Created: (TEIID-754) LOCATE() function isn't being translated correctly by Oracle Connector
by Larry O'Leary (JIRA)
LOCATE() function isn't being translated correctly by Oracle Connector
----------------------------------------------------------------------
Key: TEIID-754
URL: https://jira.jboss.org/jira/browse/TEIID-754
Project: Teiid
Issue Type: Bug
Components: JDBC Connector
Affects Versions: 6.1.0, 6.0.0, 6.2.0
Reporter: Larry O'Leary
Assignee: Larry O'Leary
Fix For: 6.2.0
The rewritten/translated query for the MMx LOCATE() function to Oracle's instr() function does not appear to be correct.
SELECT locate(INTNUM, '234567890', 1) FROM SMALLA WHERE INTKEY = 26
Is being rewritten for Oracle as:
SELECT instr('234567890', to_char(SmallA.IntNum), 2) FROM SmallA WHERE SmallA.IntKey = 26
In this case Oracle will return 0 for instr() because Oracle starts at position 1.
The query should be:
SELECT instr('234567890', to_char(SmallA.IntNum), 1) FROM SmallA WHERE SmallA.IntKey = 26
Furthermore, if I pass a negative value to LOCATE() it appears we assume position 1. If the negative value is sent to Oracle, Oracle goes from the end of the string. We should prevent this (if not already).
In 5.5.1 the rewritten query is even different and may ore may not be correct. I have not checked 5.5.3/5.5.4 and/or Westport/Teiid.
Here are the test cases that should cover this issue:
public void testRewriteLocate() throws Exception {
String input = "SELECT locate(INTNUM, 'chimp', 1) FROM SMALLA"; //$NON-NLS-1$
String output = "SELECT instr('chimp', to_char(SmallA.IntNum), 1) FROM SmallA"; //$NON-NLS-1$
helpTestVisitor(getTestVDBPath(),
input,
new Integer(TranslatedCommand.EXEC_TYPE_QUERY),
output);
}
public void testRewriteLocate2() throws Exception {
String input = "SELECT locate(STRINGNUM, 'chimp') FROM SMALLA"; //$NON-NLS-1$
String output = "SELECT instr('chimp', SmallA.StringNum) FROM SmallA"; //$NON-NLS-1$
helpTestVisitor(getTestVDBPath(),
input,
new Integer(TranslatedCommand.EXEC_TYPE_QUERY),
output);
}
public void testRewriteLocate3() throws Exception {
String input = "SELECT locate(INTNUM, '234567890', 1) FROM SMALLA WHERE INTKEY = 26"; //$NON-NLS-1$
String output = "SELECT instr('234567890', to_char(SmallA.IntNum), 1) FROM SmallA WHERE SmallA.IntKey = 26"; //$NON-NLS-1$
helpTestVisitor(getTestVDBPath(),
input,
new Integer(TranslatedCommand.EXEC_TYPE_QUERY),
output);
}
public void testRewriteLocate4() throws Exception {
String input = "SELECT locate('c', 'chimp', 1) FROM SMALLA"; //$NON-NLS-1$
String output = "SELECT 1 FROM SmallA"; //$NON-NLS-1$
helpTestVisitor(getTestVDBPath(),
input,
new Integer(TranslatedCommand.EXEC_TYPE_QUERY),
output);
}
public void testRewriteLocate5() throws Exception {
String input = "SELECT locate(STRINGNUM, 'chimp', -5) FROM SMALLA"; //$NON-NLS-1$
String output = "SELECT instr('chimp', SmallA.StringNum, 1) FROM SmallA"; //$NON-NLS-1$
helpTestVisitor(getTestVDBPath(),
input,
new Integer(TranslatedCommand.EXEC_TYPE_QUERY),
output);
}
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://jira.jboss.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
15 years, 9 months
[JBoss JIRA] Created: (TEIID-1102) Create a replacement for the text translator
by Steve Hawkins (JIRA)
Create a replacement for the text translator
--------------------------------------------
Key: TEIID-1102
URL: https://jira.jboss.org/browse/TEIID-1102
Project: Teiid
Issue Type: Feature Request
Components: Misc. Connectors, Query Engine
Affects Versions: 7.0
Reporter: Steve Hawkins
Assignee: Steve Hawkins
Fix For: 7.0
The current solution for the text connector requires the use of an external metadata file. This complicates the user experience with integrating text. An alternative approach would be to offer a built-in table function for text parsing:
TEXTTABLE(expression COLUMNS column [, column]* [DELIMITER char] [(QUOTE|ESCAPE) char] [HEADER [integer]] [SKIP integer]) AS identifier
column := identifier datatype [WIDTH integer]
If width is specified for one column it must be specified for all columns.
If width is specified, then fixed width parsing is used and ESCAPE, QUOTE, and HEADER should not be specified.
expression - the text content to process, which should be convertable to CLOB.
DELIMITER sets the field delimiter character to use. Defaults to ','.
QUOTE sets the quote, or qualifier, character used to wrap field values. Defaults to '"'.
ESCAPE sets the escape character to use if no quoting character is in use. This is used in situations where the delimiter or new line characters are escaped with a preceding character, e.g. \,
HEADER specifies the text line number (counting every new line) on which the column names occur. All lines prior to the header will be skipped.
If HEADER is specified, then the header line will be used to determine the TEXTTABLE column position by case-insensitive name matching. This is especially useful in situations where only a subset of the columns are needed.
If the HEADER value is not specified, it defaults to 1.
If HEADER is not specified, then columns are expected to match positionally with the text contents.
SKIP specifies the number of text lines (counting every new line) to skip before parsing the contents. HEADER may still be specified with SKP.
this would be implicitly a nested table, so it could be used to process multiple files:
select x.* from t, texttable(t.clobcolumn COLUMNS first string, second date SKIP 1) x
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://jira.jboss.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
15 years, 9 months
[JBoss JIRA] Created: (TEIID-739) JDBC Connector updates
by Steven Hawkins (JIRA)
JDBC Connector updates
----------------------
Key: TEIID-739
URL: https://jira.jboss.org/jira/browse/TEIID-739
Project: Teiid
Issue Type: Feature Request
Components: JDBC Connector
Affects Versions: 6.2.0
Reporter: Steven Hawkins
Assignee: Steven Hawkins
Fix For: 6.2.0
The PostgreSQL translator should assume the use of a 8.0 jdbc client (supports back to the 7.2 server) so that we can remove DatePartFunctionModifer/ModifiedDatePartFunctionModifer also support for the bit functions should be added.
The SQL Server translator / capabilities should be updated to assume the use of a 2005, DataDirect, or later driver (all support back to sql server 2000) so that support for most of the time functions can be added.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://jira.jboss.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
15 years, 9 months