Class FindLimit0SqlVisitor

java.lang.Object
org.apache.calcite.sql.util.SqlBasicVisitor<org.apache.calcite.sql.SqlNode>
org.apache.calcite.sql.util.SqlShuttle
org.apache.drill.exec.planner.sql.parser.FindLimit0SqlVisitor
All Implemented Interfaces:
org.apache.calcite.sql.util.SqlVisitor<org.apache.calcite.sql.SqlNode>

public class FindLimit0SqlVisitor extends org.apache.calcite.sql.util.SqlShuttle
A visitor that is very similar to FindLimit0SqlVisitor in that it looks for a LIMIT 0 in the root portion of the query tree for the sake of enabling optimisations but that is different in the following aspects. 1. This visitor enables the ExecConstants.FILE_LISTING_LIMIT0_OPT optimisation which takes effect during query validation, before the query has been converted to a RelNode tree. 2. This visitor is less thorough about discovering usable LIMIT 0 nodes because of the preceding point. For example, it does not even try to make use of LIMIT 0s that are present in CTEs (see SqlKind.WITH_ITEM below). Since the real targets of LIMIT 0 optimisations are schema probing queries which almost always have their LIMIT 0 on the outermost SELECT, this visitor should nevertheless do the job sufficiently. 3. This visitor is interested in whether any scanned input data is needed for the query's results, rather than whether there are zero results e.g. aggregates like SUM return a single (null) result even when they have zero inputs.
  • Nested Class Summary

    Nested classes/interfaces inherited from class org.apache.calcite.sql.util.SqlShuttle

    org.apache.calcite.sql.util.SqlShuttle.CallCopyingArgHandler

    Nested classes/interfaces inherited from class org.apache.calcite.sql.util.SqlBasicVisitor

    org.apache.calcite.sql.util.SqlBasicVisitor.ArgHandler<R extends Object>, org.apache.calcite.sql.util.SqlBasicVisitor.ArgHandlerImpl<R extends Object>
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static boolean
    containsLimit0(org.apache.calcite.sql.SqlNode sql)
    Do a non-exhaustive check of whether the root portion of the SQL node tree contains LIMIT(0)
    org.apache.calcite.sql.SqlNode
    visit(org.apache.calcite.sql.SqlCall call)
     

    Methods inherited from class org.apache.calcite.sql.util.SqlShuttle

    visit, visit, visit, visit, visit, visit

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface org.apache.calcite.sql.util.SqlVisitor

    visitNode
  • Constructor Details

    • FindLimit0SqlVisitor

      public FindLimit0SqlVisitor()
  • Method Details

    • containsLimit0

      public static boolean containsLimit0(org.apache.calcite.sql.SqlNode sql)
      Do a non-exhaustive check of whether the root portion of the SQL node tree contains LIMIT(0)
      Parameters:
      sql - SQL node tree
      Returns:
      true if the root portion of the tree contains LIMIT(0)
    • visit

      public org.apache.calcite.sql.SqlNode visit(org.apache.calcite.sql.SqlCall call)
      Specified by:
      visit in interface org.apache.calcite.sql.util.SqlVisitor<org.apache.calcite.sql.SqlNode>
      Overrides:
      visit in class org.apache.calcite.sql.util.SqlShuttle