org.apache.spark.sql.catalyst.analysis

SimpleAnalyzer

Related Doc: package analysis

object SimpleAnalyzer extends Analyzer

A trivial Analyzer with an EmptyCatalog and EmptyFunctionRegistry. Used for testing when all relations are already filled in and the analyzer needs only to resolve attribute references.

Linear Supertypes
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. SimpleAnalyzer
  2. Analyzer
  3. CheckAnalysis
  4. HiveTypeCoercion
  5. RuleExecutor
  6. Logging
  7. AnyRef
  8. Any
  1. Hide All
  2. Show all
Learn more about member selection
Visibility
  1. Public
  2. All

Type Members

  1. case class Batch(name: String, strategy: Strategy, rules: Rule[TreeType]*) extends Product with Serializable

    A batch of rules.

    A batch of rules.

    Attributes
    protected
    Definition Classes
    RuleExecutor
  2. case class FixedPoint(maxIterations: Int) extends Strategy with Product with Serializable

    A strategy that runs until fix point or maxIterations times, whichever comes first.

    A strategy that runs until fix point or maxIterations times, whichever comes first.

    Definition Classes
    RuleExecutor
  3. abstract class Strategy extends AnyRef

    An execution strategy for rules that indicates the maximum number of executions.

    An execution strategy for rules that indicates the maximum number of executions. If the execution reaches fix point (i.e. converge) before maxIterations, it will stop.

    Definition Classes
    RuleExecutor

Value Members

  1. final def !=(arg0: Any): Boolean

    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean

    Definition Classes
    AnyRef → Any
  4. object BooleanCasts extends Rule[LogicalPlan]

    Casts to/from BooleanType are transformed into comparisons since the JVM does not consider Booleans to be numeric types.

    Casts to/from BooleanType are transformed into comparisons since the JVM does not consider Booleans to be numeric types.

    Definition Classes
    HiveTypeCoercion
  5. object BooleanComparisons extends Rule[LogicalPlan]

    Changes Boolean values to Bytes so that expressions like true < false can be Evaluated.

    Changes Boolean values to Bytes so that expressions like true < false can be Evaluated.

    Definition Classes
    HiveTypeCoercion
  6. object CTESubstitution extends Rule[LogicalPlan]

    Substitute child plan with cte definitions

    Substitute child plan with cte definitions

    Definition Classes
    Analyzer
  7. object CaseWhenCoercion extends Rule[LogicalPlan]

    Coerces the type of different branches of a CASE WHEN statement to a common type.

    Coerces the type of different branches of a CASE WHEN statement to a common type.

    Definition Classes
    HiveTypeCoercion
  8. object ConvertNaNs extends Rule[LogicalPlan]

    Converts string "NaN"s that are in binary operators with a NaN-able types (Float / Double) to the appropriate numeric equivalent.

    Converts string "NaN"s that are in binary operators with a NaN-able types (Float / Double) to the appropriate numeric equivalent.

    Definition Classes
    HiveTypeCoercion
  9. object DecimalPrecision extends Rule[LogicalPlan]

    Calculates and propagates precision for fixed-precision decimals.

    Calculates and propagates precision for fixed-precision decimals. Hive has a number of rules for this based on the SQL standard and MS SQL: https://cwiki.apache.org/confluence/download/attachments/27362075/Hive_Decimal_Precision_Scale_Support.pdf https://msdn.microsoft.com/en-us/library/ms190476.aspx

    In particular, if we have expressions e1 and e2 with precision/scale p1/s2 and p2/s2 respectively, then the following operations have the following precision / scale:

    Operation Result Precision Result Scale ------------------------------------------------------------------------ e1 + e2 max(s1, s2) + max(p1-s1, p2-s2) + 1 max(s1, s2) e1 - e2 max(s1, s2) + max(p1-s1, p2-s2) + 1 max(s1, s2) e1 * e2 p1 + p2 + 1 s1 + s2 e1 / e2 p1 - s1 + s2 + max(6, s1 + p2 + 1) max(6, s1 + p2 + 1) e1 % e2 min(p1-s1, p2-s2) + max(s1, s2) max(s1, s2) e1 union e2 max(s1, s2) + max(p1-s1, p2-s2) max(s1, s2) sum(e1) p1 + 10 s1 avg(e1) p1 + 4 s1 + 4

    Catalyst also has unlimited-precision decimals. For those, all ops return unlimited precision.

    To implement the rules for fixed-precision types, we introduce casts to turn them to unlimited precision, do the math on unlimited-precision numbers, then introduce casts back to the required fixed precision. This allows us to do all rounding and overflow handling in the cast-to-fixed-precision operator.

    In addition, when mixing non-decimal types with decimals, we use the following rules: - BYTE gets turned into DECIMAL(3, 0) - SHORT gets turned into DECIMAL(5, 0) - INT gets turned into DECIMAL(10, 0) - LONG gets turned into DECIMAL(20, 0) - FLOAT and DOUBLE

    1. Union operation: FLOAT gets turned into DECIMAL(7, 7), DOUBLE gets turned into DECIMAL(15, 15) (this is the same as Hive) 2. Other operation: FLOAT and DOUBLE cause fixed-length decimals to turn into DOUBLE (this is the same as Hive, but note that unlimited decimals are considered bigger than doubles in WidenTypes)
    Definition Classes
    HiveTypeCoercion
  10. object Division extends Rule[LogicalPlan]

    Hive only performs integral division with the DIV operator.

    Hive only performs integral division with the DIV operator. The arguments to / are always converted to fractional types.

    Definition Classes
    HiveTypeCoercion
  11. object ExpectedInputConversion extends Rule[LogicalPlan]

    Casts types according to the expected input types for Expressions that have the trait ExpectsInputTypes.

    Casts types according to the expected input types for Expressions that have the trait ExpectsInputTypes.

    Definition Classes
    HiveTypeCoercion
  12. object ExtractWindowExpressions extends Rule[LogicalPlan]

    Extracts WindowExpressions from the projectList of a Project operator and aggregateExpressions of an Aggregate operator and creates individual Window operators for every distinct WindowSpecDefinition.

    Extracts WindowExpressions from the projectList of a Project operator and aggregateExpressions of an Aggregate operator and creates individual Window operators for every distinct WindowSpecDefinition.

    This rule handles three cases:

    • A Project having WindowExpressions in its projectList;
    • An Aggregate having WindowExpressions in its aggregateExpressions.
    • An Filter->Aggregate pattern representing GROUP BY with a HAVING clause and the Aggregate has WindowExpressions in its aggregateExpressions. Note: If there is a GROUP BY clause in the query, aggregations and corresponding filters (expressions in the HAVING clause) should be evaluated before any WindowExpression. If a query has SELECT DISTINCT, the DISTINCT part should be evaluated after all WindowExpressions.

    For every case, the transformation works as follows: 1. For a list of Expressions (a projectList or an aggregateExpressions), partitions it two lists of Expressions, one for all WindowExpressions and another for all regular expressions. 2. For all WindowExpressions, groups them based on their WindowSpecDefinitions. 3. For every distinct WindowSpecDefinition, creates a Window operator and inserts it into the plan tree.

    Definition Classes
    Analyzer
  13. object FunctionArgumentConversion extends Rule[LogicalPlan]

    This ensure that the types for various functions are as expected.

    This ensure that the types for various functions are as expected.

    Definition Classes
    HiveTypeCoercion
  14. object GlobalAggregates extends Rule[LogicalPlan]

    Turns projections that contain aggregate expressions into aggregations.

    Turns projections that contain aggregate expressions into aggregations.

    Definition Classes
    Analyzer
  15. object InConversion extends Rule[LogicalPlan]

    Convert all expressions in in() list to the left operator type

    Convert all expressions in in() list to the left operator type

    Definition Classes
    HiveTypeCoercion
  16. object Once extends Strategy with Product with Serializable

    A strategy that only runs once.

    A strategy that only runs once.

    Definition Classes
    RuleExecutor
  17. object PromoteStrings extends Rule[LogicalPlan]

    Promotes strings that appear in arithmetic expressions.

    Promotes strings that appear in arithmetic expressions.

    Definition Classes
    HiveTypeCoercion
  18. object PropagateTypes extends Rule[LogicalPlan]

    Applies any changes to AttributeReference data types that are made by other rules to instances higher in the query tree.

    Applies any changes to AttributeReference data types that are made by other rules to instances higher in the query tree.

    Definition Classes
    HiveTypeCoercion
  19. object ResolveFunctions extends Rule[LogicalPlan]

    Replaces UnresolvedFunctions with concrete Expressions.

    Replaces UnresolvedFunctions with concrete Expressions.

    Definition Classes
    Analyzer
  20. object ResolveGenerate extends Rule[LogicalPlan]

    Rewrites table generating expressions that either need one or more of the following in order to be resolved:

    Rewrites table generating expressions that either need one or more of the following in order to be resolved:

    • concrete attribute references for their output.
    • to be relocated from a SELECT clause (i.e. from a Project) into a Generate).

    Names for the output Attributes are extracted from Alias or MultiAlias expressions that wrap the Generator. If more than one Generator is found in a Project, an AnalysisException is throw.

    Definition Classes
    Analyzer
  21. object ResolveGroupingAnalytics extends Rule[LogicalPlan]

    Definition Classes
    Analyzer
  22. object ResolveReferences extends Rule[LogicalPlan]

    Replaces UnresolvedAttributes with concrete AttributeReferences from a logical plan node's children.

    Replaces UnresolvedAttributes with concrete AttributeReferences from a logical plan node's children.

    Definition Classes
    Analyzer
  23. object ResolveRelations extends Rule[LogicalPlan]

    Replaces UnresolvedRelations with concrete relations from the catalog.

    Replaces UnresolvedRelations with concrete relations from the catalog.

    Definition Classes
    Analyzer
  24. object ResolveSortReferences extends Rule[LogicalPlan]

    In many dialects of SQL it is valid to sort by attributes that are not present in the SELECT clause.

    In many dialects of SQL it is valid to sort by attributes that are not present in the SELECT clause. This rule detects such queries and adds the required attributes to the original projection, so that they will be available during sorting. Another projection is added to remove these attributes after sorting.

    Definition Classes
    Analyzer
  25. object StringToIntegralCasts extends Rule[LogicalPlan]

    When encountering a cast from a string representing a valid fractional number to an integral type the jvm will throw a java.lang.NumberFormatException.

    When encountering a cast from a string representing a valid fractional number to an integral type the jvm will throw a java.lang.NumberFormatException. Hive, in contrast, returns the truncated version of this number.

    Definition Classes
    HiveTypeCoercion
  26. object TrimGroupingAliases extends Rule[LogicalPlan]

    Removes no-op Alias expressions from the plan.

    Removes no-op Alias expressions from the plan.

    Definition Classes
    Analyzer
  27. object UnresolvedHavingClauseAttributes extends Rule[LogicalPlan]

    This rule finds expressions in HAVING clause filters that depend on unresolved attributes.

    This rule finds expressions in HAVING clause filters that depend on unresolved attributes. It pushes these expressions down to the underlying aggregates and then projects them away above the filter.

    Definition Classes
    Analyzer
  28. object WidenTypes extends Rule[LogicalPlan]

    Widens numeric types and converts strings to numbers when appropriate.

    Widens numeric types and converts strings to numbers when appropriate.

    Loosely based on rules from "Hadoop: The Definitive Guide" 2nd edition, by Tom White

    The implicit conversion rules can be summarized as follows:

    • Any integral numeric type can be implicitly converted to a wider type.
    • All the integral numeric types, FLOAT, and (perhaps surprisingly) STRING can be implicitly converted to DOUBLE.
    • TINYINT, SMALLINT, and INT can all be converted to FLOAT.
    • BOOLEAN types cannot be converted to any other type.

    Additionally, all types when UNION-ed with strings will be promoted to strings. Other string conversions are handled by PromoteStrings.

    Widening types might result in loss of precision in the following cases: - IntegerType to FloatType - LongType to FloatType - LongType to DoubleType

    Definition Classes
    HiveTypeCoercion
  29. object WindowsSubstitution extends Rule[LogicalPlan]

    Substitute child plan with WindowSpecDefinitions.

    Substitute child plan with WindowSpecDefinitions.

    Definition Classes
    Analyzer
  30. final def asInstanceOf[T0]: T0

    Definition Classes
    Any
  31. lazy val batches: Seq[Batch]

    Defines a sequence of rule batches, to be overridden by the implementation.

    Defines a sequence of rule batches, to be overridden by the implementation.

    Definition Classes
    AnalyzerRuleExecutor
  32. def checkAnalysis(plan: LogicalPlan): Unit

    Definition Classes
    CheckAnalysis
  33. def clone(): AnyRef

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  34. def containsMultipleGenerators(exprs: Seq[Expression]): Boolean

    Definition Classes
    CheckAnalysis
  35. final def eq(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  36. def equals(arg0: Any): Boolean

    Definition Classes
    AnyRef → Any
  37. def execute(plan: LogicalPlan): LogicalPlan

    Executes the batches of rules defined by the subclass.

    Executes the batches of rules defined by the subclass. The batches are executed serially using the defined execution strategy. Within each batch, rules are also executed serially.

    Definition Classes
    RuleExecutor
  38. val extendedCheckRules: Seq[(LogicalPlan) ⇒ Unit]

    Override to provide additional checks for correct analysis.

    Override to provide additional checks for correct analysis. These rules will be evaluated after our built-in check rules.

    Definition Classes
    CheckAnalysis
  39. val extendedResolutionRules: Seq[Rule[LogicalPlan]]

    Override to provide additional rules for the "Resolution" batch.

    Override to provide additional rules for the "Resolution" batch.

    Definition Classes
    Analyzer
  40. def failAnalysis(msg: String): Nothing

    Attributes
    protected
    Definition Classes
    CheckAnalysis
  41. def finalize(): Unit

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  42. val fixedPoint: FixedPoint

    Definition Classes
    Analyzer
  43. final def getClass(): Class[_]

    Definition Classes
    AnyRef → Any
  44. def hashCode(): Int

    Definition Classes
    AnyRef → Any
  45. final def isInstanceOf[T0]: Boolean

    Definition Classes
    Any
  46. def isTraceEnabled(): Boolean

    Attributes
    protected
    Definition Classes
    Logging
  47. def log: Logger

    Attributes
    protected
    Definition Classes
    Logging
  48. def logDebug(msg: ⇒ String, throwable: Throwable): Unit

    Attributes
    protected
    Definition Classes
    Logging
  49. def logDebug(msg: ⇒ String): Unit

    Attributes
    protected
    Definition Classes
    Logging
  50. def logError(msg: ⇒ String, throwable: Throwable): Unit

    Attributes
    protected
    Definition Classes
    Logging
  51. def logError(msg: ⇒ String): Unit

    Attributes
    protected
    Definition Classes
    Logging
  52. def logInfo(msg: ⇒ String, throwable: Throwable): Unit

    Attributes
    protected
    Definition Classes
    Logging
  53. def logInfo(msg: ⇒ String): Unit

    Attributes
    protected
    Definition Classes
    Logging
  54. def logName: String

    Attributes
    protected
    Definition Classes
    Logging
  55. def logTrace(msg: ⇒ String, throwable: Throwable): Unit

    Attributes
    protected
    Definition Classes
    Logging
  56. def logTrace(msg: ⇒ String): Unit

    Attributes
    protected
    Definition Classes
    Logging
  57. def logWarning(msg: ⇒ String, throwable: Throwable): Unit

    Attributes
    protected
    Definition Classes
    Logging
  58. def logWarning(msg: ⇒ String): Unit

    Attributes
    protected
    Definition Classes
    Logging
  59. final def ne(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  60. final def notify(): Unit

    Definition Classes
    AnyRef
  61. final def notifyAll(): Unit

    Definition Classes
    AnyRef
  62. def resolver: Resolver

    Definition Classes
    Analyzer
  63. final def synchronized[T0](arg0: ⇒ T0): T0

    Definition Classes
    AnyRef
  64. def toString(): String

    Definition Classes
    AnyRef → Any
  65. val typeCoercionRules: List[Rule[LogicalPlan]]

    Definition Classes
    HiveTypeCoercion
  66. final def wait(): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  67. final def wait(arg0: Long, arg1: Int): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  68. final def wait(arg0: Long): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Inherited from Analyzer

Inherited from CheckAnalysis

Inherited from HiveTypeCoercion

Inherited from RuleExecutor[LogicalPlan]

Inherited from Logging

Inherited from AnyRef

Inherited from Any

Ungrouped