6 Replies Latest reply on Apr 22, 2012 9:11 PM by jeffreykwok

    Date range criteria of Yahoo Translator

    jeffreykwok

      I would like to extend sandbox's yahoo translator to allow it support a date range selection in the query. However, when i execute the query [select * from yahoostock where symbol='xxx' AND dateprice bwtween  '2010-02-03' and '2012-05-05''  condition in the query, I found the this criteria is removed by teiid.  (i updated the date field to dateprice in the code already which is the original date column return from yahoo)

       

      e.g, when I print out the query object in the YahooExecution directly, I found  that the " date bwtween  '2010-02-03' and '2012-05-05'  " criteria is not exited . the print out is  "select * from yahoostock where symbol='xxx'"

       

      How can I get the dateprice condition from the inputted query so that I can update the yahoo url ?

        • 1. Re: Date range criteria of Yahoo Translator
          rareddy

          Jeffery,

           

          You would need to extend the YahooExecutionFactory' class and provide "supportsBetweenCriteria" override method that returns true. Then you need to modify the "YahooExecution" class's execute method and handle "between" clause to handle and change it to appropriate Yahoo URL. Take look at 'TickerCollectorVisitor' class for example of how to traverse a query.

           

          HTH

           

          Ramesh..

          • 2. Re: Date range criteria of Yahoo Translator
            jeffreykwok

            Thx Ramesh.  "

            @Override

                public boolean supportsBetweenCriteria() {

                    return true;

              }

            is added before. However, the print out of the command in ExecutionFactory  still remove the between condition..

             

            >>>>>

             

            @Override

                public ResultSetExecution createResultSetExecution(QueryExpression command, ExecutionContext executionContext, RuntimeMetadata metadata, Object connectionFactory)

                        throws TranslatorException {

             

                    System.out.println("command->" +command.toString());

                    return new YahooExecution((Select)command, metadata);

                }

            >>>>>>

            If change the sql to  " where dateprice='xxx' and symbol ='xxx'"   -> then the select command can return the original input sql correctly

            if the sql is  "where dateprice >= '2012-02-02'   and symbol ='xxx'  ->  the print out command  is   '  where symbol ='xxx'  again.

             

            Due to the incorrect command passed to the factory, i cannot get correct expression objects in TickerCollectorVisitor methods.

            • 3. Re: Date range criteria of Yahoo Translator
              rareddy

              >= is a different option. , see "supportsCompareCriteriaOrdered". For all the options see the JavaDoc on the ExecutionFactory class.

              1 of 1 people found this helpful
              • 4. Re: Date range criteria of Yahoo Translator
                shawkins

                Between predicates are converted by the rewriter to => and <=, see the JavaDoc for supportsBetweenCriteria - it was only left for backwards capatiblity and should probably be removed for Teiid 8.

                • 5. Re: Date range criteria of Yahoo Translator
                  rareddy
                  • 6. Re: Date range criteria of Yahoo Translator
                    jeffreykwok

                    Thx. After i add supportsCompareCriteriaOrdered and change the query to  >= and <= criteria, it solved my problem