本文整理汇总了Golang中github.com/pingcap/tidb/expression.Schema.ToString方法的典型用法代码示例。如果您正苦于以下问题:Golang Schema.ToString方法的具体用法?Golang Schema.ToString怎么用?Golang Schema.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/pingcap/tidb/expression.Schema
的用法示例。
在下文中一共展示了Schema.ToString方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: makeUsedList
func makeUsedList(usedCols []*expression.Column, schema expression.Schema) []bool {
used := make([]bool, len(schema))
for _, col := range usedCols {
idx := schema.GetIndex(col)
if idx == -1 {
log.Errorf("Can't find column %s from schema %s.", col.ToString(), schema.ToString())
}
used[idx] = true
}
return used
}
示例2: columnSubstitute
// columnSubstitute substitutes the columns in filter to expressions in select fields.
// e.g. select * from (select b as a from t) k where a < 10 => select * from (select b as a from t where b < 10) k.
func columnSubstitute(expr expression.Expression, schema expression.Schema, newExprs []expression.Expression) expression.Expression {
switch v := expr.(type) {
case *expression.Column:
id := schema.GetIndex(v)
if id == -1 {
log.Errorf("Can't find columns %s in schema %s", v.ToString(), schema.ToString())
}
return newExprs[id]
case *expression.ScalarFunction:
for i, arg := range v.Args {
v.Args[i] = columnSubstitute(arg, schema, newExprs)
}
}
return expr
}
示例3: retrieveColumnsInExpression
func retrieveColumnsInExpression(expr expression.Expression, schema expression.Schema) (
expression.Expression, error) {
switch v := expr.(type) {
case *expression.ScalarFunction:
for i, arg := range v.Args {
newExpr, err := retrieveColumnsInExpression(arg, schema)
if err != nil {
return nil, errors.Trace(err)
}
v.Args[i] = newExpr
}
case *expression.Column:
if !v.Correlated {
newColumn := schema.RetrieveColumn(v)
if newColumn == nil {
return nil, errors.Errorf("Can't Find column %s from schema %s.", expr.ToString(), schema.ToString())
}
return newColumn, nil
}
}
return expr, nil
}