[teiid-issues] [JBoss JIRA] Commented: (TEIID-1401) QueryRewriter issue with certain UDFs

Mark Drilling (JIRA) jira-events at lists.jboss.org
Fri Dec 17 16:00:18 EST 2010


    [ https://issues.jboss.org/browse/TEIID-1401?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12571144#comment-12571144 ] 

Mark Drilling commented on TEIID-1401:
--------------------------------------

Per Steve's look at the QueryRewriter code:
----------------
The simplest fix is to change the logic:

        if(funcName.startsWith("parse")) { //$NON-NLS-1$
            String type = funcName.substring(5);
            inverseFunction = "format" + type; //$NON-NLS-1$
        } else if(funcName.startsWith("format")) { //$NON-NLS-1$
            String type = funcName.substring(6);
            inverseFunction = "parse" + type; //$NON-NLS-1$
        } else {
            return crit;
        }

to something more explicit:

    private static final Set<String> PARSE_FORMAT_TYPES = new HashSet<String>(Arrays.asList(DataTypeManager.DefaultDataTypes.TIME,
                    DataTypeManager.DefaultDataTypes.DATE, DataTypeManager.DefaultDataTypes.TIMESTAMP, DataTypeManager.DefaultDataTypes.BIG_DECIMAL,
                    DataTypeManager.DefaultDataTypes.BIG_INTEGER, DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.LONG,
                    DataTypeManager.DefaultDataTypes.FLOAT, DataTypeManager.DefaultDataTypes.DOUBLE));


...


        if(funcName.startsWith("parse")) { //$NON-NLS-1$
            String type = funcName.substring(5);
            if (!PARSE_FORMAT_TYPES.contains(type)) {
                return crit;
            }
            inverseFunction = "format" + type; //$NON-NLS-1$
        } else if(funcName.startsWith("format")) { //$NON-NLS-1$
            String type = funcName.substring(6);
            if (!PARSE_FORMAT_TYPES.contains(type)) {
                return crit;
            }
            inverseFunction = "parse" + type; //$NON-NLS-1$
        } else {
            return crit;
        }
----------------

> QueryRewriter issue with certain UDFs
> -------------------------------------
>
>                 Key: TEIID-1401
>                 URL: https://issues.jboss.org/browse/TEIID-1401
>             Project: Teiid
>          Issue Type: Bug
>          Components: Query Engine
>    Affects Versions: 7.2
>            Reporter: Mark Drilling
>            Assignee: Steven Hawkins
>
> Encountered NPE in QueryRewriter with the following stacktrace:
> java.lang.ArrayIndexOutOfBoundsException: 1
> 	at com.metamatrix.query.rewriter.QueryRewriter.simplifyParseFormatFunction(QueryRewriter.java:1690)
> 	at com.metamatrix.query.rewriter.QueryRewriter.simplifyWithInverse(QueryRewriter.java:1368)
> 	at com.metamatrix.query.rewriter.QueryRewriter.rewriteCriteria(QueryRewriter.java:1314)
> 	at com.metamatrix.query.rewriter.QueryRewriter.rewriteCriteria(QueryRewriter.java:1112)
> 	at com.metamatrix.query.rewriter.QueryRewriter.rewriteCriteria(QueryRewriter.java:1095)
> 	at com.metamatrix.query.rewriter.QueryRewriter.rewriteCriteria(QueryRewriter.java:1091)
> 	at com.metamatrix.query.optimizer.relational.rules.FrameUtil.convertCriteria(FrameUtil.java:537)
> The issue was traced back to usage of a UDF named 'parsedate_'.  The QueryRewriter makes assumption about function starting with the word 'parse'.  see next comment for more info.

-- 
This message is automatically generated by JIRA.
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the teiid-issues mailing list