object ResolveDefaultColumns extends QueryErrorsBase with ResolveDefaultColumnsUtils
This object contains fields to help process DEFAULT columns.
- Alphabetic
- By Inheritance
- ResolveDefaultColumns
- ResolveDefaultColumnsUtils
- QueryErrorsBase
- DataTypeErrorsBase
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
##(): Int
- Definition Classes
- AnyRef → Any
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
val
CURRENT_DEFAULT_COLUMN_METADATA_KEY: String
- Definition Classes
- ResolveDefaultColumnsUtils
- val CURRENT_DEFAULT_COLUMN_NAME: String
-
val
EXISTS_DEFAULT_COLUMN_METADATA_KEY: String
- Definition Classes
- ResolveDefaultColumnsUtils
-
def
analyze(colName: String, dataType: DataType, defaultSQL: String, statementType: String): Expression
Parses and analyzes the DEFAULT column SQL string, returning an error upon failure.
Parses and analyzes the DEFAULT column SQL string, returning an error upon failure.
- returns
Result of the analysis and constant-folding operation.
-
def
analyze(field: StructField, statementType: String, metadataKey: String = CURRENT_DEFAULT_COLUMN_METADATA_KEY): Expression
Parses and analyzes the DEFAULT column text in
field, returning an error upon failure.Parses and analyzes the DEFAULT column text in
field, returning an error upon failure.- field
represents the DEFAULT column value whose "default" metadata to parse and analyze.
- statementType
which type of statement we are running, such as INSERT; useful for errors.
- metadataKey
which key to look up from the column metadata; generally either CURRENT_DEFAULT_COLUMN_METADATA_KEY or EXISTS_DEFAULT_COLUMN_METADATA_KEY.
- returns
Result of the analysis and constant-folding operation.
-
def
applyExistenceDefaultValuesToRow(schema: StructType, row: InternalRow, bitmask: Array[Boolean]): Unit
Updates a subset of columns in the row with default values from the metadata in the schema.
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
def
clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( ... ) @native()
-
def
constantFoldCurrentDefaultsToExistDefaults(tableSchema: StructType, statementType: String): StructType
Finds "current default" expressions in CREATE/REPLACE TABLE columns and constant-folds them.
Finds "current default" expressions in CREATE/REPLACE TABLE columns and constant-folds them.
The results are stored in the "exists default" metadata of the same columns. For example, in the event of this statement:
CREATE TABLE T(a INT, b INT DEFAULT 5 + 5)
This method constant-folds the "current default" value, stored in the CURRENT_DEFAULT metadata of the "b" column, to "10", storing the result in the "exists default" value within the EXISTS_DEFAULT metadata of that same column. Meanwhile the "current default" metadata of this "b" column retains its original value of "5 + 5".
The reason for constant-folding the EXISTS_DEFAULT is to make the end-user visible behavior the same, after executing an ALTER TABLE ADD COLUMNS command with DEFAULT value, as if the system had performed an exhaustive backfill of the provided value to all previously existing rows in the table instead. We choose to avoid doing such a backfill because it would be a time-consuming and costly operation. Instead, we elect to store the EXISTS_DEFAULT in the column metadata for future reference when querying data out of the data source. In turn, each data source then takes responsibility to provide the constant-folded value in the EXISTS_DEFAULT metadata for such columns where the value is not present in storage.
- tableSchema
represents the names and types of the columns of the statement to process.
- statementType
name of the statement being processed, such as INSERT; useful for errors.
- returns
a copy of
tableSchemawith field metadata updated with the constant-folded values.
-
def
containsExplicitDefaultColumn(expr: Expression): Boolean
Returns true if the given expression contains an explicit DEFAULT column reference.
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
equals(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
existenceDefaultValues(schema: StructType): Array[Any]
These define existence default values for the struct fields for efficiency purposes.
These define existence default values for the struct fields for efficiency purposes. The caller should avoid using such methods in a loop for efficiency.
- def existenceDefaultsBitmask(schema: StructType): Array[Boolean]
-
def
finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( classOf[java.lang.Throwable] )
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
def
getDefaultValueExprOrNullLit(attr: Attribute, useNullAsDefault: Boolean): Option[NamedExpression]
Generates the expression of the default value for the given attribute.
Generates the expression of the default value for the given attribute. If there is no user-specified default value for this attribute, returns null literal if
useNullAsDefaultis true and the attribute is nullable. -
def
getDefaultValueExprOrNullLit(field: StructField, useNullAsDefault: Boolean): Option[NamedExpression]
Generates the expression of the default value for the given field.
Generates the expression of the default value for the given field. If there is no user-specified default value for this field, returns null literal if
useNullAsDefaultis true and the field is nullable. -
def
getDefaultValueExprOrNullLit(attr: Attribute): Expression
Generates the expression of the default value for the given attribute.
Generates the expression of the default value for the given attribute. If there is no user-specified default value for this attribute and the attribute is nullable, returns null literal, otherwise an exception is thrown.
-
def
getDefaultValueExprOrNullLit(field: StructField): Expression
Generates the expression of the default value for the given field.
Generates the expression of the default value for the given field. If there is no user-specified default value for this field and the field is nullable, returns null literal, otherwise an exception is thrown.
-
def
getDescribeMetadata(schema: StructType): Seq[(String, String, String)]
If any fields in a schema have default values, appends them to the result.
-
def
getExistenceDefaultValues(schema: StructType): Array[Any]
Parses the text representing constant-folded default column literal values.
Parses the text representing constant-folded default column literal values. These are known as "existence" default values because each one is the constant-folded result of the original default value first assigned to the column at table/column creation time. When scanning a field from any data source, if the corresponding value is not present in storage, the output row returns this "existence" default value instead of NULL.
- returns
a sequence of either (1) NULL, if the column had no default value, or (2) an object of Any type suitable for assigning into a row using the InternalRow.update method.
-
def
getExistenceDefaultsBitmask(schema: StructType): Array[Boolean]
Returns an array of boolean values equal in size to the result of getExistenceDefaultValues above, for convenience.
-
def
getQueryContext(sqlContext: SQLQueryContext): Array[QueryContext]
- Definition Classes
- DataTypeErrorsBase
-
def
getSummary(sqlContext: SQLQueryContext): String
- Definition Classes
- DataTypeErrorsBase
- def hasExistenceDefaultValues(schema: StructType): Boolean
-
def
hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
def
isExplicitDefaultColumn(col: UnresolvedAttribute): Boolean
Returns true if the unresolved column is an explicit DEFAULT column reference.
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
normalizeFieldName(str: String): String
Normalizes a schema field name suitable for use in looking up into maps keyed by schema field names.
Normalizes a schema field name suitable for use in looking up into maps keyed by schema field names.
- str
the field name to normalize
- returns
the normalized result
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
def
quoteByDefault(elem: String): String
- Attributes
- protected
- Definition Classes
- DataTypeErrorsBase
-
def
resetExistenceDefaultsBitmask(schema: StructType, bitmask: Array[Boolean]): Unit
Resets the elements of the array initially returned from getExistenceDefaultsBitmask above.
Resets the elements of the array initially returned from getExistenceDefaultsBitmask above. Afterwards, set element(s) to false before calling applyExistenceDefaultValuesToRow below.
-
def
resolveColumnDefaultInAssignmentValue(key: Expression, value: Expression, invalidColumnDefaultException: Throwable): Expression
Resolves the column "DEFAULT" in UPDATE/MERGE assignment value expression if the following conditions are met: 1.
Resolves the column "DEFAULT" in UPDATE/MERGE assignment value expression if the following conditions are met: 1. The assignment value expression is a single
UnresolvedAttributewith name "DEFAULT". This meanskey = DEFAULTis allowed butkey = DEFAULT + 1is not. 2. The assignment key expression is a top-level column. This meanscol = DEFAULTis allowed butcol.field = DEFAULTis not.The column "DEFAULT" will be resolved to the default value expression defined for the column of the assignment key.
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
def
toDSOption(option: String): String
- Definition Classes
- QueryErrorsBase
-
def
toSQLConf(conf: String): String
- Definition Classes
- DataTypeErrorsBase
-
def
toSQLConfVal(conf: String): String
- Definition Classes
- QueryErrorsBase
-
def
toSQLExpr(e: Expression): String
- Definition Classes
- QueryErrorsBase
-
def
toSQLId(parts: Seq[String]): String
- Definition Classes
- DataTypeErrorsBase
-
def
toSQLId(parts: String): String
- Definition Classes
- DataTypeErrorsBase
-
def
toSQLSchema(schema: String): String
- Definition Classes
- QueryErrorsBase
-
def
toSQLStmt(text: String): String
- Definition Classes
- DataTypeErrorsBase
-
def
toSQLType(t: AbstractDataType): String
- Definition Classes
- DataTypeErrorsBase
-
def
toSQLType(text: String): String
- Definition Classes
- DataTypeErrorsBase
-
def
toSQLValue(v: Any, t: DataType): String
- Definition Classes
- QueryErrorsBase
-
def
toSQLValue(value: Double): String
- Definition Classes
- DataTypeErrorsBase
-
def
toSQLValue(value: Float): String
- Definition Classes
- DataTypeErrorsBase
-
def
toSQLValue(value: Long): String
- Definition Classes
- DataTypeErrorsBase
-
def
toSQLValue(value: Int): String
- Definition Classes
- DataTypeErrorsBase
-
def
toSQLValue(value: Short): String
- Definition Classes
- DataTypeErrorsBase
-
def
toSQLValue(value: UTF8String): String
- Definition Classes
- DataTypeErrorsBase
-
def
toSQLValue(value: String): String
- Definition Classes
- DataTypeErrorsBase
-
def
toString(): String
- Definition Classes
- AnyRef → Any
- def validateCatalogForDefaultValue(schema: StructType, catalog: TableCatalog, ident: Identifier): Unit
- def validateTableProviderForDefaultValue(schema: StructType, tableProvider: Option[String], statementType: String, addNewColumnToExistingTable: Boolean): Unit
-
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... ) @native()
-
object
BuiltInFunctionCatalog extends FunctionCatalog
This is a FunctionCatalog for performing analysis using built-in functions only.
This is a FunctionCatalog for performing analysis using built-in functions only. It is a helper for the DefaultColumnAnalyzer above.
-
object
DefaultColumnAnalyzer extends Analyzer
This is an Analyzer for processing default column values using built-in functions only.
-
object
DefaultColumnOptimizer extends Optimizer
This is an Optimizer for convert default column expressions to foldable literals.