plan

package
v0.0.0-debug-20260702 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 2, 2026 License: Apache-2.0 Imports: 89 Imported by: 0

Documentation

Overview

Copyright 2024 Matrix Origin

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

View Source
const (
	UnsupportedIndexCondition = 0
	EqualIndexCondition       = 1
	NonEqualIndexCondition    = 2
	SpatialIndexCondition     = 3
	RangeIndexCondition       = 4

	// MaxOverFetchFactor is the maximum multiplier for over-fetching candidates
	// in auto mode vector search. This cap prevents excessive memory usage and
	// candidate processing when filter selectivity is very low (e.g., 0.001).
	// Value of 100 means we fetch at most 100x the original LIMIT value.
	MaxOverFetchFactor = 100.0
)
View Source
const (
	TimeWindowStart = "_wstart"
	TimeWindowEnd   = "_wend"
)
View Source
const (
	LoadParallelMinSize = int(colexec.WriteS3Threshold)
	LoadWriteS3MinSize  = 1 << 20
)
View Source
const (
	NotSampleByRows     = -1
	NotSampleByPercents = -1.0
)
View Source
const (
	ParseJsonlFormatLine   = "line"   // treat each line as a single json value
	ParseJsonlFormatArray  = "array"  // each line is an array
	ParseJsonlFormatObject = "object" // each line is an object

	ParseJsonlTypeBool      = "bool"
	ParseJsonlTypeInt32     = "int32"
	ParseJsonlTypeInt64     = "int64"
	ParseJsonlTypeTimestamp = "timestamp"
	ParseJsonlTypeFloat32   = "float32"
	ParseJsonlTypeFloat64   = "float64"
	ParseJsonlTypeString    = "string"
)
View Source
const (
	InFilterCardLimitNonPK   = 10000
	InFilterCardLimitPK      = 1000000
	BloomFilterCardLimit     = 100 * InFilterCardLimitNonPK
	InFilterSelectivityLimit = 0.3
)
View Source
const (
	ShuffleThreshHoldOfNDV          = 50000
	ShuffleTypeThreshHoldLowerLimit = 16
	ShuffleTypeThreshHoldUpperLimit = 1024
)
View Source
const (
	ShuffleToRegIndex        int32 = 0
	ShuffleToLocalMatchedReg int32 = 1
	ShuffleToMultiMatchedReg int32 = 2
)
View Source
const (
	MoLocksColTypeCnId = iota
	//MoLocksColTypeSessionId
	MoLocksColTypeTxnId
	MoLocksColTypeTableId
	//MoLocksColTypeTableName
	MoLocksColTypeLockKey
	MoLocksColTypeLockContent
	MoLocksColTypeLockMode
	MoLocksColTypeLockStatus
	MoLocksColTypeLockWait
)
View Source
const (
	MoConfigColTypeNodeType = iota
	MoConfigColTypeNodeId
	MoConfigColTypeName
	MoConfigColTypeCurrentValue
	MoConfigColTypeDefaultValue
	MoConfigColTypeInternal
)
View Source
const (
	MoTransactionsColTypeCnId = iota
	MoTransactionsColTypeTxnId
	MoTransactionsColTypeCreateTs
	MoTransactionsColTypeSnapshotTs
	MoTransactionsColTypePreparedTs
	MoTransactionsColTypeCommitTs
	MoTransactionsColTypeTxnMode
	MoTransactionsColTypeIsolation
	MoTransactionsColTypeUserTxn
	MoTransactionsColTypeTxnStatus
	MoTransactionsColTypeTableId
	MoTransactionsColTypeLockKey
	MoTransactionsColTypeLockContent
	MoTransactionsColTypeLockMode
)
View Source
const (
	MoCacheColTypeNodeType = iota
	MoCacheColTypeNodeId
	MoCacheColTypeType
	MoCacheColTypeUsed
	MoCacheColTypeFree
	MoCacheColTypeHitRatio
)
View Source
const (
	JoinSideNone       int8 = 0
	JoinSideLeft            = 1 << 1
	JoinSideRight           = 1 << 2
	JoinSideBoth            = JoinSideLeft | JoinSideRight
	JoinSideMark            = 1 << 3
	JoinSideCorrelated      = 1 << 4
	JoinSideOuter           = 1 << 5
)
View Source
const (
	// does not bind cte currently
	CteBindTypeNone = 0
	// bind initial select stmt of recursive cte currently
	CteBindTypeInitStmt = 1
	// bind recursive parts of recursive cte currently
	CteBindTypeRecurStmt = 2
	// bind non recursive cte currently
	CteBindTypeNonRecur = 3
)
View Source
const (
	NotFound      int32 = math.MaxInt32
	AmbiguousName int32 = math.MinInt32
)
View Source
const BlockThresholdForOneCN = 512
View Source
const CSVCommentKey = "comment"

CSVCommentKey is the external-table option that sets the CSV reader's comment marker: a line whose raw prefix (before unquoting) equals it is skipped on read. The default (option absent or empty) is no marker — every line is data.

View Source
const ExternalWriteFilePatternKey = "write_file_pattern"

ExternalWriteFilePatternKey is the external-table option that turns the table into a writable external table. Its value is a strftime template (with the %nN and %U MatrixOne extensions) that must resolve to a stage:// path.

View Source
const INFORMATION_SCHEMA = "information_schema"
View Source
const LargeBlockThresholdForMultiCN = 32
View Source
const LargeBlockThresholdForOneCN = 4
View Source
const MO_CATALOG_DB_NAME = "mo_catalog"
View Source
const MO_DEFUALT_HOSTNAME = "localhost"
View Source
const (
	// MaxFsp is the maximum digit of fractional seconds part.
	MaxFsp = 6
)
View Source
const (
	/*
		Identifier Length Limits
		See MySQL: https://dev.mysql.com/doc/refman/8.0/en/identifiers.html
	*/
	// MaxKeyParts is max length of key parts.
	MaxKeyParts = 16
)
View Source
const NameClusterCenters = "cluster_centers"
View Source
const NameGroupConcat = "group_concat"
View Source
const PKHostIdVirtualName = "__mo_pk_host_id"

PKHostIdVirtualName is the reserved identifier for predicates routed to the index's host_ids array (external primary keys) on the C++ side, instead of to a FilterStore column. Users must not create a table column with this name and then declare it as an INCLUDE column; the planner would redirect the predicate to host_ids and the FilterStore copy would be unused dead weight.

View Source
const (
	// PrimaryKeyName defines primary key name.
	PrimaryKeyName = "PRIMARY"
)
View Source
const RowSizeThreshold = 128

RowSizeThreshold Regardless of the table, the minimum row size is 100. However, due to inaccurate statistical information, the RowSizeThreshold is tentatively set at 128, and it is only used for tables with vector indexes

View Source
const SF float64 = 1
View Source
const SYSMOCATALOGPITR = "sys_mo_catalog_pitr"
View Source
const (
	/*
		https://dev.mysql.com/doc/refman/8.0/en/column-count-limit.html
		MySQL has hard limit of 4096 columns per table, but the effective maximum may be less for a given table.
	*/
	TableColumnCountLimit = 4096
)
View Source
const UnKnownColId uint64 = math.MaxUint64
View Source
const ViewSnapshotKeySuffix = "@ts="

Variables

View Source
var (
	MetadataScanColDefs   = []*plan.ColDef{}
	MetadataScanColTypes  = []types.Type{}
	Metadata_Rows_Cnt_Pos int32
)
View Source
var (
	TableStatsColDefs  []*plan.ColDef
	TableStatsColTypes []types.Type
)
View Source
var ForceAssignmentCastExpr = forceAssignmentCastExpr
View Source
var ForceCastExpr = forceCastExpr
View Source
var ForceScanOnMultiCN atomic.Bool

for test

View Source
var MakePlan2BoolConstExprWithType = makePlan2BoolConstExprWithType
View Source
var MakePlan2DateConstExprWithType = makePlan2DateConstExprWithType
View Source
var MakePlan2DateTimeConstExprWithType = makePlan2DateTimeConstExprWithType
View Source
var MakePlan2Float32ConstExprWithType = makePlan2Float32ConstExprWithType
View Source
var MakePlan2Float64ConstExprWithType = makePlan2Float64ConstExprWithType
View Source
var MakePlan2Int16ConstExprWithType = makePlan2Int16ConstExprWithType
View Source
var MakePlan2Int32ConstExprWithType = makePlan2Int32ConstExprWithType
View Source
var MakePlan2Int64ConstExprWithType = makePlan2Int64ConstExprWithType
View Source
var MakePlan2Int64VecExprWithType = makePlan2Int64VecExprWithType
View Source
var MakePlan2Int8ConstExprWithType = makePlan2Int8ConstExprWithType
View Source
var MakePlan2StringConstExprWithType = makePlan2StringConstExprWithType
View Source
var MakePlan2StringVecExprWithType = makePlan2StringVecExprWithType
View Source
var MakePlan2TimeConstExprWithType = makePlan2TimeConstExprWithType
View Source
var MakePlan2TimestampConstExprWithType = makePlan2TimestampConstExprWithType
View Source
var MakePlan2Type = makePlan2Type
View Source
var MakePlan2TypeValue = makePlan2TypeValue
View Source
var MakePlan2Uint16ConstExprWithType = makePlan2Uint16ConstExprWithType
View Source
var MakePlan2Uint32ConstExprWithType = makePlan2Uint32ConstExprWithType
View Source
var MakePlan2Uint64ConstExprWithType = makePlan2Uint64ConstExprWithType
View Source
var MakePlan2Uint8ConstExprWithType = makePlan2Uint8ConstExprWithType
View Source
var MakePlan2Vecf32ConstExprWithType = makePlan2Vecf32ConstExprWithType
View Source
var MakePlan2Vecf64ConstExprWithType = makePlan2Vecf64ConstExprWithType
View Source
var MakeTypeByPlan2Expr = makeTypeByPlan2Expr
View Source
var MakeTypeByPlan2Type = makeTypeByPlan2Type
View Source
var (
	MetaColDefs = []*plan.ColDef{
		{
			Name: catalog.MetaColNames[catalog.QUERY_ID_IDX],
			Typ: plan.Type{
				Id:          int32(catalog.MetaColTypes[catalog.QUERY_ID_IDX].Oid),
				NotNullable: false,
			},
		},
		{
			Name: catalog.MetaColNames[catalog.STATEMENT_IDX],
			Typ: plan.Type{
				Id:          int32(catalog.MetaColTypes[catalog.STATEMENT_IDX].Oid),
				NotNullable: false,
			},
		},
		{
			Name: catalog.MetaColNames[catalog.ACCOUNT_ID_IDX],
			Typ: plan.Type{
				Id:          int32(catalog.MetaColTypes[catalog.ACCOUNT_ID_IDX].Oid),
				NotNullable: false,
			},
		},
		{
			Name: catalog.MetaColNames[catalog.ROLE_ID_IDX],
			Typ: plan.Type{
				Id:          int32(catalog.MetaColTypes[catalog.ROLE_ID_IDX].Oid),
				NotNullable: false,
			},
		},
		{
			Name: catalog.MetaColNames[catalog.RESULT_PATH_IDX],
			Typ: plan.Type{
				Id:          int32(catalog.MetaColTypes[catalog.RESULT_PATH_IDX].Oid),
				NotNullable: false,
				Width:       4,
			},
		},
		{
			Name: catalog.MetaColNames[catalog.CREATE_TIME_IDX],
			Typ: plan.Type{
				Id:          int32(catalog.MetaColTypes[catalog.CREATE_TIME_IDX].Oid),
				NotNullable: false,
			},
		},
		{
			Name: catalog.MetaColNames[catalog.RESULT_SIZE_IDX],
			Typ: plan.Type{
				Id:          int32(catalog.MetaColTypes[catalog.RESULT_SIZE_IDX].Oid),
				NotNullable: false,
			},
		},
		{
			Name: catalog.MetaColNames[catalog.TABLES_IDX],
			Typ: plan.Type{
				Id:          int32(catalog.MetaColTypes[catalog.TABLES_IDX].Oid),
				NotNullable: false,
			},
		},
		{
			Name: catalog.MetaColNames[catalog.USER_ID_IDX],
			Typ: plan.Type{
				Id:          int32(catalog.MetaColTypes[catalog.USER_ID_IDX].Oid),
				NotNullable: false,
			},
		},
		{
			Name: catalog.MetaColNames[catalog.EXPIRED_TIME_IDX],
			Typ: plan.Type{
				Id:          int32(catalog.MetaColTypes[catalog.EXPIRED_TIME_IDX].Oid),
				NotNullable: false,
			},
		},
		{
			Name: catalog.MetaColNames[catalog.COLUMN_MAP_IDX],
			Typ: plan.Type{
				Id:          int32(catalog.MetaColTypes[catalog.COLUMN_MAP_IDX].Oid),
				NotNullable: false,
			},
		},
		{
			Name: catalog.MetaColNames[catalog.SAVED_ROW_COUNT_IDX],
			Typ: plan.Type{
				Id:          int32(catalog.MetaColTypes[catalog.SAVED_ROW_COUNT_IDX].Oid),
				NotNullable: false,
			},
		},
		{
			Name: catalog.MetaColNames[catalog.QUERY_ROW_COUNT_IDX],
			Typ: plan.Type{
				Id:          int32(catalog.MetaColTypes[catalog.QUERY_ROW_COUNT_IDX].Oid),
				NotNullable: false,
			},
		},
	}
)
View Source
var MoCacheColName2Index = map[string]int32{
	"node_type": 0,
	"node_id":   1,
	"type":      2,
	"used":      3,
	"free":      4,
	"hit_ratio": 5,
}
View Source
var MoCacheColNames = []string{
	"node_type",
	"node_id",
	"type",
	"used",
	"free",
	"hit_ratio",
}
View Source
var MoConfigColName2Index = map[string]int32{
	"node_type":     0,
	"node_id":       1,
	"name":          2,
	"current_value": 3,
	"default_value": 4,
	"internal":      5,
}
View Source
var MoConfigColNames = []string{
	"node_type",
	"node_id",
	"name",
	"current_value",
	"default_value",
	"internal",
}
View Source
var MoLocksColName2Index = map[string]int32{
	"cn_id":        0,
	"txn_id":       1,
	"table_id":     2,
	"lock_key":     3,
	"lock_content": 4,
	"lock_mode":    5,
	"lock_status":  6,
	"lock_wait":    7,
}
View Source
var MoLocksColNames = []string{
	"cn_id",

	"txn_id",
	"table_id",

	"lock_key",
	"lock_content",
	"lock_mode",
	"lock_status",
	"lock_wait",
}
View Source
var MoTransactionsColName2Index = map[string]int32{
	"cn_id":        0,
	"txn_id":       1,
	"create_ts":    2,
	"snapshot_ts":  3,
	"prepared_ts":  4,
	"commit_ts":    5,
	"txn_mode":     6,
	"isolation":    7,
	"user_txn":     8,
	"txn_status":   9,
	"table_id":     10,
	"lock_key":     11,
	"lock_content": 12,
	"lock_mode":    13,
}
View Source
var MoTransactionsColNames = []string{
	"cn_id",
	"txn_id",
	"create_ts",
	"snapshot_ts",
	"prepared_ts",
	"commit_ts",
	"txn_mode",
	"isolation",
	"user_txn",
	"txn_status",
	"table_id",
	"lock_key",
	"lock_content",
	"lock_mode",
}
View Source
var (
	STATEMENT_ACCOUNT = "account"
)
View Source
var Sequence_cols_name = []string{"last_seq_num", "min_value", "max_value", "start_value", "increment_value", "cycle", "is_called"}
View Source
var SessionsColTypes []types.Type

Functions

func AddColumn added in v1.0.0

func AddColumn(
	ctx CompilerContext,
	alterPlan *plan.AlterTable,
	spec *tree.AlterAddCol,
	alterCtx *AlterTableContext,
) (bool, error)

AddColumn will add a new column to the table.

func AddPrimaryKey added in v1.0.0

func AddPrimaryKey(ctx CompilerContext, alterPlan *plan.AlterTable, spec *tree.PrimaryKeyIndex, alterCtx *AlterTableContext) error

AddPrimaryKey will add a new column to the table.

func AdjustNDV

func AdjustNDV(info *TableStatsInfo, tableDef *TableDef, s *pb.StatsInfo)

func AlterColumn added in v1.0.0

func AlterColumn(
	ctx CompilerContext,
	alterPlan *plan.AlterTable,
	spec *tree.AlterTableAlterColumnClause,
	alterCtx *AlterTableContext,
) (bool, error)

AlterColumn ALTER ... SET DEFAULT or ALTER ... DROP DEFAULT specify a new default value for a column or remove the old default value, respectively. If the old default is removed and the column can be NULL, the new default is NULL. If the column cannot be NULL, MySQL assigns a default value

func AssignAuxIdForExpr added in v0.8.0

func AssignAuxIdForExpr(expr *plan.Expr, start int32) int32

func BindFuncExprImplByPlanExpr added in v0.8.0

func BindFuncExprImplByPlanExpr(ctx context.Context, name string, args []*Expr) (*plan.Expr, error)

func BuildVectorsByData added in v0.7.0

func BuildVectorsByData(datas [][2]any, dataTypes []uint8, mp *mpool.MPool) []*vector.Vector

func ByteSliceToUint64 added in v1.0.0

func ByteSliceToUint64(bytes []byte) uint64

convert first 8 bytes to uint64, slice might be less than 8 bytes

func CalcNodeDOP

func CalcNodeDOP(p *plan.Plan, rootID int32, ncpu int32, lencn int)

func CalcQueryDOP

func CalcQueryDOP(p *plan.Plan, ncpu int32, lencn int, typ ExecType)

func CalcRangeShuffleIDXForObj

func CalcRangeShuffleIDXForObj(rsp *engine.RangesShuffleParam, objstats *objectio.ObjectStats, bucketNum int) uint64

func ChangeColumn added in v1.0.0

func ChangeColumn(
	cctx CompilerContext,
	alterPlan *plan.AlterTable,
	spec *tree.AlterTableChangeColumnClause,
	alterCtx *AlterTableContext,
) (bool, error)

ChangeColumn Can rename a column and change its definition, or both. Has more capability than MODIFY or RENAME COLUMN, but at the expense of convenience for some operations. CHANGE requires naming the column twice if not renaming it, and requires respecifying the column definition if only renaming it. With FIRST or AFTER, can reorder columns.

func ConstantFold added in v0.6.0

func ConstantFold(bat *batch.Batch, expr *plan.Expr, proc *process.Process, varAndParamIsConst bool, foldInExpr bool) (*plan.Expr, error)

func ConstantTranspose

func ConstantTranspose(expr *plan.Expr, proc *process.Process) (*plan.Expr, error)

func ConstructCreateTableSQL added in v1.2.1

func ConstructCreateTableSQL(
	ctx CompilerContext,
	tableDef *plan.TableDef,
	snapshot *Snapshot,
	useDbName bool,
	cloneStmt *tree.CloneTable,
) (string, tree.Statement, error)

ConstructCreateTableSQL used to build CREATE Table statement

func CreateIndexDef added in v1.1.0

func CreateIndexDef(ctx planplugin.CompilerContext, indexInfo *tree.Index,
	indexTableName, indexAlgoTableType string,
	indexParts []string, isUnique bool) (*plan.IndexDef, error)

func DbNameOfObjRef

func DbNameOfObjRef(objRef *ObjectRef) string

DbNameOfObjRef return subscription name of ObjectRef if exists, to avoid the mismatching of account id and db name

func DeepCopyAnalyzeInfo added in v0.7.0

func DeepCopyAnalyzeInfo(analyzeinfo *plan.AnalyzeInfo) *plan.AnalyzeInfo

func DeepCopyClusterTable added in v0.7.0

func DeepCopyClusterTable(cluster *plan.ClusterTable) *plan.ClusterTable

func DeepCopyColData added in v0.6.0

func DeepCopyColData(col *plan.ColData) *plan.ColData

func DeepCopyColDef added in v0.6.0

func DeepCopyColDef(col *plan.ColDef) *plan.ColDef

func DeepCopyColDefList

func DeepCopyColDefList(colDefs []*plan.ColDef) []*plan.ColDef

func DeepCopyDataDefinition added in v0.6.0

func DeepCopyDataDefinition(old *plan.DataDefinition) *plan.DataDefinition

func DeepCopyDedupJoinCtx

func DeepCopyDedupJoinCtx(ctx *plan.DedupJoinCtx) *plan.DedupJoinCtx

func DeepCopyDefault added in v0.6.0

func DeepCopyDefault(def *plan.Default) *plan.Default

func DeepCopyDeleteCtx added in v0.7.0

func DeepCopyDeleteCtx(ctx *plan.DeleteCtx) *plan.DeleteCtx

func DeepCopyDropTable

func DeepCopyDropTable(src *plan.DropTable) *plan.DropTable

func DeepCopyGeneratedCol

func DeepCopyGeneratedCol(old *plan.GeneratedCol) *plan.GeneratedCol

func DeepCopyIndexDef added in v0.7.0

func DeepCopyIndexDef(indexDef *plan.IndexDef) *plan.IndexDef

func DeepCopyIndexOption added in v1.1.0

func DeepCopyIndexOption(indexOption *plan.IndexOption) *plan.IndexOption

func DeepCopyIndexReaderParam

func DeepCopyIndexReaderParam(oldParam *plan.IndexReaderParam) *plan.IndexReaderParam

func DeepCopyInsertCtx added in v0.7.0

func DeepCopyInsertCtx(ctx *plan.InsertCtx) *plan.InsertCtx

func DeepCopyLockTarget added in v0.8.0

func DeepCopyLockTarget(target *plan.LockTarget) *plan.LockTarget

func DeepCopyNode added in v0.6.0

func DeepCopyNode(node *plan.Node) *plan.Node

func DeepCopyObjectRef added in v0.7.0

func DeepCopyObjectRef(ref *plan.ObjectRef) *plan.ObjectRef

func DeepCopyOnUpdate added in v0.6.0

func DeepCopyOnUpdate(old *plan.OnUpdate) *plan.OnUpdate

func DeepCopyOrderBySpec

func DeepCopyOrderBySpec(orderBy *plan.OrderBySpec) *plan.OrderBySpec

func DeepCopyOrderBySpecList

func DeepCopyOrderBySpecList(orderByList []*plan.OrderBySpec) []*plan.OrderBySpec

func DeepCopyPreInsertCtx added in v0.8.0

func DeepCopyPreInsertCtx(ctx *plan.PreInsertCtx) *plan.PreInsertCtx

func DeepCopyPreInsertUkCtx added in v0.8.0

func DeepCopyPreInsertUkCtx(ctx *plan.PreInsertUkCtx) *plan.PreInsertUkCtx

func DeepCopyPrimaryKeyDef added in v0.7.0

func DeepCopyPrimaryKeyDef(pkeyDef *plan.PrimaryKeyDef) *plan.PrimaryKeyDef

func DeepCopyQuery added in v0.6.0

func DeepCopyQuery(qry *plan.Query) *plan.Query

func DeepCopyRankOption

func DeepCopyRankOption(opt *plan.RankOption) *plan.RankOption

func DeepCopyRuntimeFilterSpec

func DeepCopyRuntimeFilterSpec(rf *plan.RuntimeFilterSpec) *plan.RuntimeFilterSpec

func DeepCopySampleFuncSpec added in v1.1.0

func DeepCopySampleFuncSpec(source *plan.SampleFuncSpec) *plan.SampleFuncSpec

func DeepCopyStats added in v1.0.0

func DeepCopyStats(stats *plan.Stats) *plan.Stats

func DeepCopyTableDef added in v0.6.0

func DeepCopyTableDef(table *plan.TableDef, withCols bool) *plan.TableDef

func DeepCopyTableDefList added in v0.8.0

func DeepCopyTableDefList(src []*plan.TableDef) []*plan.TableDef

func DeepCopyType added in v0.8.0

func DeepCopyType(typ *plan.Type) *plan.Type

func DeepCopyUpdateCtxList

func DeepCopyUpdateCtxList(updateCtxList []*plan.UpdateCtx) []*plan.UpdateCtx

func DefaultBigStats

func DefaultBigStats() *plan.Stats

func DefaultHugeStats added in v0.8.0

func DefaultHugeStats() *plan.Stats

func DefaultMinimalStats added in v1.1.0

func DefaultMinimalStats() *plan.Stats

func DefaultStats added in v0.7.0

func DefaultStats() *plan.Stats

func DefaultValueIsNull added in v1.0.0

func DefaultValueIsNull(Default *plan.Default) bool

func DropColumn added in v1.0.0

func DropColumn(
	ctx CompilerContext,
	alterPlan *plan.AlterTable,
	colName string,
	alterCtx *AlterTableContext,
) (bool, error)

AddColumn will add a new column to the table.

func DropPrimaryKey added in v1.0.0

func DropPrimaryKey(ctx CompilerContext, alterPlan *plan.AlterTable, alterCtx *AlterTableContext) error

func EscapeFormat added in v1.2.1

func EscapeFormat(s string) string

EscapeFormat output escape character with backslash.

func EvalFilterExpr added in v0.7.0

func EvalFilterExpr(ctx context.Context, expr *plan.Expr, bat *batch.Batch, proc *process.Process) (bool, error)

func EvalFoldExpr

func EvalFoldExpr(proc *process.Process, expr *Expr, executors *[]colexec.ExpressionExecutor) (err error)

func ExprIsZonemappable added in v1.1.1

func ExprIsZonemappable(ctx context.Context, expr *plan.Expr) bool

func ExprType2Type

func ExprType2Type(typ *plan.Type) types.Type

func ExtractToDateReturnType added in v0.8.0

func ExtractToDateReturnType(format string) (tp types.T, fsp int)

func Find added in v1.2.1

func Find[T ~string | ~int, S any](data map[T]S, val T) bool

func FormatColType added in v1.2.1

func FormatColType(colType plan.Type) string

FormatColType Get the formatted description of the column type.

func FormatExpr added in v0.8.0

func FormatExpr(expr *plan.Expr, option FormatOption) string

func FormatExprInConsole

func FormatExprInConsole(expr *plan.Expr, option FormatOption) string

func FormatExprs added in v1.2.0

func FormatExprs(exprs []*plan.Expr, option FormatOption) string

func FormatExprsInConsole

func FormatExprsInConsole(exprs []*plan.Expr, option FormatOption) string

func FormatViewKeyWithSnapshot

func FormatViewKeyWithSnapshot(viewKey string, snapshot *Snapshot) string

FormatViewKeyWithSnapshot appends snapshot information to a view key for privilege checks.

func GenConstraintName added in v1.1.2

func GenConstraintName() string

GenConstraintName yields uuid for the constraint name

func GetBindings added in v0.5.0

func GetBindings(expr *plan.Expr) []int32

func GetCSVComment

func GetCSVComment(param *tree.ExternParam) string

GetCSVComment returns the COMMENT option of an external table (empty when unset, meaning no comment marker).

func GetCenterValueExtractFromZMSigned

func GetCenterValueExtractFromZMSigned(zm objectio.ZoneMap, t types.T) int64

func GetCenterValueExtractFromZMUnsigned

func GetCenterValueExtractFromZMUnsigned(zm objectio.ZoneMap, t types.T) uint64

func GetCenterValueForZMSigned added in v1.1.0

func GetCenterValueForZMSigned(zm objectio.ZoneMap) int64

func GetCenterValueForZMUnsigned added in v1.1.0

func GetCenterValueForZMUnsigned(zm objectio.ZoneMap) uint64

func GetColExpr

func GetColExpr(typ Type, relpos int32, colpos int32) *plan.Expr

func GetColumnMapByExpr added in v0.8.0

func GetColumnMapByExpr(expr *plan.Expr, tableDef *plan.TableDef, columnMap map[int]int)

func GetColumnMapByExprs added in v0.8.0

func GetColumnMapByExprs(exprs []*plan.Expr, tableDef *plan.TableDef, columnMap map[int]int)

func GetColumnsByExpr added in v0.7.0

func GetColumnsByExpr(
	expr *plan.Expr,
	tableDef *plan.TableDef,
) (columnMap map[int]int, defColumns, exprColumns []int, maxCol int)

func GetFilePathFromParam

func GetFilePathFromParam(param *tree.ExternParam) string

func GetFkReferredTo added in v1.1.2

func GetFkReferredTo(ctx CompilerContext, db, table string) (map[FkReferKey]map[string][]*FkReferDef, error)

GetFkReferredTo returns the foreign key relationships that refer to the table

func GetForETLWithType added in v0.7.0

func GetForETLWithType(param *tree.ExternParam, prefix string) (res fileservice.ETLFileService, readPath string, err error)

func GetForceScanOnMultiCN

func GetForceScanOnMultiCN() bool

func GetFunctionArgTypeStrFromAst added in v1.1.0

func GetFunctionArgTypeStrFromAst(arg tree.FunctionArg) (string, error)

GetFunctionArgTypeStrFromAst function arg type do not have scale and width, it depends on the data that it process

func GetFunctionTypeStrFromAst added in v1.1.0

func GetFunctionTypeStrFromAst(typRef tree.ResolvableTypeReference) (string, error)

func GetHashColumn added in v0.8.0

func GetHashColumn(expr *plan.Expr) (*plan.ColRef, int32)

func GetInFilterCardLimit added in v1.1.1

func GetInFilterCardLimit(sid string) int32

func GetInFilterCardLimitOnPK added in v1.2.0

func GetInFilterCardLimitOnPK(
	sid string,
	tableCnt float64,
) int32

func GetPhyPlanTitle

func GetPhyPlanTitle(qry *plan.Query, txnHaveDDL bool) string

func GetPlanTitle

func GetPlanTitle(qry *plan.Query, txnHaveDDL bool) string

func GetRangeShuffleIndexForExtractedZM

func GetRangeShuffleIndexForExtractedZM(minVal, maxVal int64, zm objectio.ZoneMap, upplerLimit uint64, t types.T) uint64

func GetRangeShuffleIndexForValuesExtractedFromZMSignedSlice

func GetRangeShuffleIndexForValuesExtractedFromZMSignedSlice(val []int64, zm objectio.ZoneMap, t types.T) uint64

func GetRangeShuffleIndexForValuesExtractedFromZMUnsignedSlice

func GetRangeShuffleIndexForValuesExtractedFromZMUnsignedSlice(val []uint64, zm objectio.ZoneMap, t types.T) uint64

func GetRangeShuffleIndexForZM added in v0.8.0

func GetRangeShuffleIndexForZM(minVal, maxVal int64, zm objectio.ZoneMap, upplerLimit uint64) uint64

func GetRangeShuffleIndexForZMSignedSlice added in v1.1.0

func GetRangeShuffleIndexForZMSignedSlice(val []int64, zm objectio.ZoneMap) uint64

func GetRangeShuffleIndexForZMUnsignedSlice added in v1.1.0

func GetRangeShuffleIndexForZMUnsignedSlice(val []uint64, zm objectio.ZoneMap) uint64

func GetRangeShuffleIndexSignedMinMax added in v1.1.0

func GetRangeShuffleIndexSignedMinMax(minVal, maxVal, currentVal int64, upplerLimit uint64) uint64

func GetRangeShuffleIndexSignedSlice added in v1.1.0

func GetRangeShuffleIndexSignedSlice(val []int64, currentVal int64) uint64

func GetRangeShuffleIndexUnsignedMinMax added in v1.1.0

func GetRangeShuffleIndexUnsignedMinMax(minVal, maxVal, currentVal uint64, upplerLimit uint64) uint64

func GetRangeShuffleIndexUnsignedSlice added in v1.1.0

func GetRangeShuffleIndexUnsignedSlice(val []uint64, currentVal uint64) uint64

func GetRowSizeFromTableDef added in v1.2.0

func GetRowSizeFromTableDef(tableDef *TableDef, ignoreHiddenKey bool) float64

func GetSortOrder added in v0.8.0

func GetSortOrder(tableDef *plan.TableDef, colPos int32) int

func GetSortOrderByName added in v1.2.0

func GetSortOrderByName(tableDef *plan.TableDef, colName string) int

func GetSqlForFkReferredTo added in v1.1.2

func GetSqlForFkReferredTo(db, table string) string

GetSqlForFkReferredTo returns the query that retrieves the fk relationships that refer to the table

func GetUniqueColAndIdxFromTableDef added in v0.8.0

func GetUniqueColAndIdxFromTableDef(tableDef *TableDef) ([]map[string]int, map[string]bool)

GetUniqueColAndIdxFromTableDef if get table: t1(a int primary key, b int, c int, d int, unique key(b,c)); return : []map[string]int { {'a'=1}, {'b'=2,'c'=3} }

func GetWriteFilePattern

func GetWriteFilePattern(param *tree.ExternParam) (string, bool)

GetWriteFilePattern returns the WRITE_FILE_PATTERN option of an external table and whether it was set. An external table is writable iff this returns ok.

func HasColExpr added in v0.8.0

func HasColExpr(expr *plan.Expr, pos int32) int32

func HasFkSelfReferOnly added in v1.1.2

func HasFkSelfReferOnly(tableDef *TableDef) bool

HasFkSelfReferOnly checks the foreign key referencing itself only. If there is no children tables, it also returns true the tbleId 0 is special. it always denotes the table itself.

func HasFoldExprForList

func HasFoldExprForList(exprs []*Expr) bool

func HasFoldValExpr

func HasFoldValExpr(expr *Expr) bool

func HasMoCtrl added in v1.1.1

func HasMoCtrl(expr *plan.Expr) bool

HasMoCtrl checks whether the expression has mo_ctrl(..,..,..)

func HasShuffleInPlan

func HasShuffleInPlan(qry *plan.Query) bool

func HasTag added in v1.1.0

func HasTag(expr *plan.Expr, tag int32) bool

func IgnoredLines

func IgnoredLines(param *tree.ExternParam, ctx CompilerContext) (offset int64, err error)

func InitInfileOrStageParam

func InitInfileOrStageParam(param *tree.ExternParam, proc *process.Process) error

func InitInfileParam added in v0.7.0

func InitInfileParam(param *tree.ExternParam) error

func InitNullMap added in v0.6.0

func InitNullMap(param *tree.ExternParam, ctx CompilerContext) error

func InitS3Param added in v0.7.0

func InitS3Param(param *tree.ExternParam) error

func InitStageS3Param

func InitStageS3Param(param *tree.ExternParam, s stage.StageDef) error

func InternalTable added in v1.2.0

func InternalTable(tableDef *TableDef) bool

func IsDefaultStats

func IsDefaultStats(stats *plan.Stats) bool

func IsEqualFunc added in v1.1.0

func IsEqualFunc(id int64) bool

func IsEquiJoin2 added in v0.8.0

func IsEquiJoin2(exprs []*plan.Expr) bool

IsEquiJoin2 Judge whether a join node is equi-join (after column remapping) Can only be used after optimizer!!!

func IsFalseExpr added in v1.2.0

func IsFalseExpr(e *Expr) bool

func IsFkBannedDatabase added in v1.1.2

func IsFkBannedDatabase(db string) bool

IsFkBannedDatabase denotes the database should not have any foreign keys

func IsFkSelfRefer added in v1.1.2

func IsFkSelfRefer(fkDbName, fkTableName, curDbName, curTableName string) bool

IsFkSelfRefer checks the foreign key referencing itself

func IsForeignKeyChecksEnabled added in v1.1.2

func IsForeignKeyChecksEnabled(ctx CompilerContext) (bool, error)

IsForeignKeyChecksEnabled returns the system variable foreign_key_checks is true or false

func IsSnapshotValid added in v1.2.0

func IsSnapshotValid(snapshot *Snapshot) bool

func MakeCPKEYRuntimeFilter

func MakeCPKEYRuntimeFilter(tag int32, upperlimit int32, expr *Expr, tableDef *plan.TableDef, notOnPk bool) *plan.RuntimeFilterSpec

func MakeInsertValueConstExpr

func MakeInsertValueConstExpr(proc *process.Process, numVal *tree.NumVal, colType *types.Type) (*plan.Expr, error)

func MakePlan2Decimal64ExprWithType added in v0.8.0

func MakePlan2Decimal64ExprWithType(v types.Decimal64, typ *Type) *plan.Expr

func MakePlan2Decimal128ExprWithType added in v0.8.0

func MakePlan2Decimal128ExprWithType(v types.Decimal128, typ *Type) *plan.Expr

func MakePlan2NullTextConstExprWithType added in v0.7.0

func MakePlan2NullTextConstExprWithType(v string) *plan.Expr

func MakeRuntimeFilter added in v1.2.0

func MakeRuntimeFilter(tag int32, matchPrefix bool, upperlimit int32, expr *Expr, notOnPk bool) *plan.RuntimeFilterSpec

func MakeSerialRuntimeFilter

func MakeSerialRuntimeFilter(ctx context.Context, tag int32, matchPrefix bool, upperlimit int32, expr *Expr, notOnPk bool) *plan.RuntimeFilterSpec

func ModifyColumn added in v1.0.0

func ModifyColumn(
	cctx CompilerContext,
	alterPlan *plan.AlterTable,
	spec *tree.AlterTableModifyColumnClause,
	alterCtx *AlterTableContext,
) (bool, error)

ModifyColumn Can change a column definition but not its name. More convenient than CHANGE to change a column definition without renaming it. With FIRST or AFTER, can reorder columns.

func NewShuffleRange added in v1.1.0

func NewShuffleRange(isString bool) *pb.ShuffleRange

func NewStatsInfo added in v1.2.0

func NewStatsInfo() *pb.StatsInfo

func OrderByColumn added in v1.0.0

func OrderByColumn(ctx CompilerContext, alterPlan *plan.AlterTable, spec *tree.AlterTableOrderByColumnClause, alterCtx *AlterTableContext) error

OrderByColumn Currently, Mo only performs semantic checks on alter table order by and does not implement the function of changing the physical storage order of data in the table

func PkColByTableDef

func PkColByTableDef(tblDef *plan.TableDef) *plan.ColDef

func PrintStats added in v0.8.0

func PrintStats(qry *plan.Query) string

func ReCalcNodeStats added in v0.7.0

func ReCalcNodeStats(nodeID int32, builder *QueryBuilder, recursive bool, leafNode bool, needResetHashMapStats bool)

func ReadDir added in v0.7.0

func ReadDir(param *tree.ExternParam) (fileList []string, fileSize []int64, err error)

ReadDir support "etl:" and "/..." absolute path, NOT support relative path.

func RemoveIf added in v1.2.1

func RemoveIf[T any](data []T, pred func(t T) bool) []T

RemoveIf removes the elements that pred is true.

func RenameColumn added in v1.0.0

func RenameColumn(
	ctx CompilerContext,
	alterPlan *plan.AlterTable,
	spec *tree.AlterTableRenameColumnClause,
	alterCtx *AlterTableContext,
) error

RenameColumn Can change a column name but not its definition. More convenient than CHANGE to rename a column without changing its definition.

func ReplaceFoldExpr

func ReplaceFoldExpr(proc *process.Process, expr *Expr, exes *[]colexec.ExpressionExecutor) (bool, error)

a > current_time() + 1 and b < ? + c and d > ? + 2 => a > foldVal1 and b < foldVal2 + c and d > foldVal3

func ResetAuxIdForExpr added in v0.8.0

func ResetAuxIdForExpr(expr *plan.Expr)

func ResetPreparePlan added in v1.1.0

func ResetPreparePlan(ctx CompilerContext, preparePlan *Plan) ([]*plan.ObjectRef, []int32, error)

func ResolveAlterTableAlgorithm added in v1.0.0

func ResolveAlterTableAlgorithm(
	ctx context.Context,
	validAlterSpecs []tree.AlterTableOption,
	tableDef *TableDef,
) (algorithm plan.AlterTable_AlgorithmType, err error)

func RewriteCountNotNullColToStarcount

func RewriteCountNotNullColToStarcount(node *plan.Node, tableDef *plan.TableDef)

RewriteCountNotNullColToStarcount rewrites count(not_null_col) to starcount (ObjName + Obj) on node.AggList so that compile uses countStarExec instead of countColumnExec. tableDef must be the child's (e.g. TABLE_SCAN).

func SetForceScanOnMultiCN

func SetForceScanOnMultiCN(v bool)

func ShouldSkipObjByShuffle

func ShouldSkipObjByShuffle(rsp *engine.RangesShuffleParam, objstats *objectio.ObjectStats) bool

func ShuffleRangeReEvalSigned added in v1.1.0

func ShuffleRangeReEvalSigned(ranges []float64, k2 int, nullCnt int64, tableCnt int64) []int64

func ShuffleRangeReEvalUnsigned added in v1.1.0

func ShuffleRangeReEvalUnsigned(ranges []float64, k2 int, nullCnt int64, tableCnt int64) []uint64

func SimpleCharHashToRange added in v0.8.0

func SimpleCharHashToRange(bytes []byte, upperLimit uint64) uint64

func SimpleInt64HashToRange added in v0.8.0

func SimpleInt64HashToRange(i uint64, upperLimit uint64) uint64

func StatFile added in v1.1.1

func StatFile(param *tree.ExternParam) error

func UpdateStatsInfo added in v1.2.0

func UpdateStatsInfo(info *TableStatsInfo, tableDef *plan.TableDef, s *pb.StatsInfo)

func VarlenaToUint64 added in v1.0.0

func VarlenaToUint64(v *types.Varlena, area []byte) uint64

convert first 8 bytes to uint64

func VarlenaToUint64Inline added in v1.0.0

func VarlenaToUint64Inline(v *types.Varlena) uint64

convert first 8 bytes to uint64. vec.area must be nil if varlena length less than 8 bytes, should have filled zero in varlena

Types

type AlterTableContext added in v1.0.0

type AlterTableContext struct {
	UpdateSqls []string
	// contains filtered or unexported fields
}

type BaseOptimizer added in v0.5.0

type BaseOptimizer struct {
	// contains filtered or unexported fields
}

BaseOptimizer is base optimizer, capable of handling only a few simple rules

func NewBaseOptimizer added in v0.5.0

func NewBaseOptimizer(ctx CompilerContext) *BaseOptimizer

func NewPrepareOptimizer added in v0.7.0

func NewPrepareOptimizer(ctx CompilerContext) *BaseOptimizer

func (*BaseOptimizer) CurrentContext added in v0.5.0

func (opt *BaseOptimizer) CurrentContext() CompilerContext

func (*BaseOptimizer) Optimize added in v0.5.0

func (opt *BaseOptimizer) Optimize(stmt tree.Statement, isPrepareStmt bool) (*Query, error)

type BindContext added in v0.5.0

type BindContext struct {
	// contains filtered or unexported fields
}

func NewBindContext added in v0.5.0

func NewBindContext(builder *QueryBuilder, parent *BindContext) *BindContext

type Binder added in v0.5.0

type Binder interface {
	BindExpr(tree.Expr, int32, bool) (*plan.Expr, error)
	BindColRef(*tree.UnresolvedName, int32, bool) (*plan.Expr, error)
	BindAggFunc(string, *tree.FuncExpr, int32, bool) (*plan.Expr, error)
	BindWinFunc(string, *tree.FuncExpr, int32, bool) (*plan.Expr, error)
	BindSubquery(*tree.Subquery, bool) (*plan.Expr, error)
	BindTimeWindowFunc(string, *tree.FuncExpr, int32, bool) (*plan.Expr, error)
	GetContext() context.Context
}

type Binding added in v0.5.0

type Binding struct {
	// contains filtered or unexported fields
}

func NewBinding added in v0.5.0

func NewBinding(tag, nodeID int32, db, table string, tableID uint64, cols []string, colIsHidden []bool, types []*plan.Type, isClusterTable bool, defaultVals []string) *Binding

func (*Binding) FindColumn added in v0.5.0

func (b *Binding) FindColumn(col string) int32

type BindingTreeNode added in v0.5.0

type BindingTreeNode struct {
	// contains filtered or unexported fields
}

type CTERef added in v0.5.0

type CTERef struct {
	// contains filtered or unexported fields
}

type ClusterByDef added in v0.7.0

type ClusterByDef = plan.ClusterByDef

type ClusterTable added in v0.7.0

type ClusterTable = plan.ClusterTable

type ColDef added in v0.5.0

type ColDef = plan.ColDef

func FindColumn added in v0.8.0

func FindColumn(cols []*ColDef, name string) *ColDef

FindColumn finds column in cols by name.

func FindColumnByColId added in v1.0.0

func FindColumnByColId(cols []*ColDef, colId uint64) *ColDef

FindColumn finds column in cols by colId

func FindColumnByOriginName

func FindColumnByOriginName(cols []*ColDef, originName string) *ColDef

FindColumnByOriginName finds column in cols by origin name.

func GetColDefFromTable added in v1.0.0

func GetColDefFromTable(Cols []*ColDef, hidenColName string) *ColDef

GetColDefFromTable Find the target column definition from the predefined table columns and return its deep copy

func GetResultColumnsFromPlan added in v0.5.0

func GetResultColumnsFromPlan(p *Plan) []*ColDef

GetResultColumnsFromPlan

func MakeHiddenColDefByName added in v0.8.0

func MakeHiddenColDefByName(name string) *ColDef

used for Compound primary key column name && clusterby column name

func MakeRowIdColDef added in v0.8.0

func MakeRowIdColDef() *ColDef

type ColRef added in v0.5.0

type ColRef = plan.ColRef

type ColRefRemapping added in v0.5.0

type ColRefRemapping struct {
	// contains filtered or unexported fields
}

func (*ColRefRemapping) String added in v1.2.2

func (m *ColRefRemapping) String() string

type CompilerContext added in v0.5.0

type CompilerContext interface {
	// Default database/schema in context
	DefaultDatabase() string
	// check if database exist
	DatabaseExists(name string, snapshot *Snapshot) bool
	// get table definition by database/schema
	Resolve(schemaName string, tableName string, snapshot *Snapshot) (*ObjectRef, *TableDef, error)
	// get index table definition by an ObjectRef, will skip unnecessary subscription check
	ResolveIndexTableByRef(ref *ObjectRef, tblName string, snapshot *Snapshot) (*ObjectRef, *TableDef, error)
	// get table definition by table id
	ResolveById(tableId uint64, snapshot *Snapshot) (*ObjectRef, *TableDef, error)
	// get the value of variable
	ResolveVariable(varName string, isSystemVar, isGlobalVar bool) (interface{}, error)
	// get the list of the account id
	ResolveAccountIds(accountNames []string) ([]uint32, error)
	// get the relevant information of udf
	ResolveUdf(name string, args []*Expr) (*function.Udf, error)
	// get needed info for stats by table, NOTE: Stats May indirectly access the file service
	Stats(obj *ObjectRef, snapshot *Snapshot) (*pb.StatsInfo, error)
	// get origin sql string of the root
	GetRootSql() string
	// get username of current session
	GetUserName() string
	GetAccountId() (uint32, error)
	GetAccountName() string
	// GetContext get raw context.Context
	GetContext() context.Context

	// SetContext set raw context.Context
	SetContext(ctx context.Context)
	// GetDatabaseId Get database id
	GetDatabaseId(dbName string, snapshot *Snapshot) (uint64, error)

	GetProcess() *process.Process

	GetQueryResultMeta(uuid string) ([]*ColDef, string, error)
	SetBuildingAlterView(yesOrNo bool, dbName, viewName string)
	// is building the alter view or not
	// return: yes or no, dbName, viewName
	GetBuildingAlterView() (bool, string, string)
	GetStatsCache() *StatsCache
	GetSubscriptionMeta(dbName string, snapshot *Snapshot) (*SubscriptionMeta, error)
	CheckSubscriptionValid(subName, accName string, pubName string) error
	SetQueryingSubscription(meta *SubscriptionMeta)
	GetQueryingSubscription() *SubscriptionMeta
	IsPublishing(dbName string) (bool, error)
	BuildTableDefByMoColumns(dbName, table string) (*TableDef, error)
	ResolveSubscriptionTableById(tableId uint64, pubmeta *SubscriptionMeta) (*ObjectRef, *TableDef, error)

	ResolveSnapshotWithSnapshotName(snapshotName string) (*Snapshot, error)
	CheckTimeStampValid(ts int64) (bool, error)

	//InitExecuteStmtParam replaces the plan of the EXECUTE by the plan generated by the PREPARE.
	//return
	//	the plan generated by the PREPARE
	//	the statement generated by the PREPARE
	InitExecuteStmtParam(execPlan *plan.Execute) (*plan.Plan, tree.Statement, error)

	GetSnapshot() *Snapshot
	SetSnapshot(snapshot *Snapshot)
	GetViews() []string
	SetViews(views []string)

	GetLowerCaseTableNames() int64
}

type Const added in v0.5.0

type Const = plan.Literal

type CteBindState

type CteBindState struct {
	// contains filtered or unexported fields
}

type DMLContext

type DMLContext struct {
	// contains filtered or unexported fields
}

func NewDMLContext

func NewDMLContext() *DMLContext

func (*DMLContext) ResolveSingleTable

func (dmlCtx *DMLContext) ResolveSingleTable(ctx CompilerContext, tbl tree.TableExpr, aliasMap map[string][2]string, withMap map[string]bool, respectFKCheck bool) error

func (*DMLContext) ResolveTables

func (dmlCtx *DMLContext) ResolveTables(ctx CompilerContext, tableExprs tree.TableExprs, with *tree.With, aliasMap map[string][2]string, respectFKCheck bool) error

func (*DMLContext) ResolveUpdateTables

func (dmlCtx *DMLContext) ResolveUpdateTables(ctx CompilerContext, stmt *tree.Update) error

type DefaultBinder added in v0.6.0

type DefaultBinder struct {
	// contains filtered or unexported fields
}

func NewDefaultBinder added in v0.6.0

func NewDefaultBinder(sysCtx context.Context, builder *QueryBuilder, ctx *BindContext, typ Type, cols []string) *DefaultBinder

func (*DefaultBinder) BindAggFunc added in v0.6.0

func (b *DefaultBinder) BindAggFunc(funcName string, astExpr *tree.FuncExpr, depth int32, isRoot bool) (*plan.Expr, error)

func (*DefaultBinder) BindColRef added in v0.6.0

func (b *DefaultBinder) BindColRef(astExpr *tree.UnresolvedName, depth int32, isRoot bool) (*plan.Expr, error)

func (*DefaultBinder) BindExpr added in v0.6.0

func (b *DefaultBinder) BindExpr(astExpr tree.Expr, depth int32, isRoot bool) (*plan.Expr, error)

func (*DefaultBinder) BindSubquery added in v0.6.0

func (b *DefaultBinder) BindSubquery(astExpr *tree.Subquery, isRoot bool) (*plan.Expr, error)

func (*DefaultBinder) BindTimeWindowFunc added in v1.1.0

func (b *DefaultBinder) BindTimeWindowFunc(funcName string, astExpr *tree.FuncExpr, depth int32, isRoot bool) (*plan.Expr, error)

func (*DefaultBinder) BindWinFunc added in v0.6.0

func (b *DefaultBinder) BindWinFunc(funcName string, astExpr *tree.FuncExpr, depth int32, isRoot bool) (*plan.Expr, error)

func (*DefaultBinder) GetContext added in v0.7.0

func (b *DefaultBinder) GetContext() context.Context

type ExecType added in v0.6.0

type ExecType int
const (
	ExecTypeTP ExecType = iota
	ExecTypeAP_ONECN
	ExecTypeAP_MULTICN
)

func GetExecType

func GetExecType(qry *plan.Query, txnHaveDDL bool, isPrepare bool) ExecType

type ExpandAliasMode added in v1.0.0

type ExpandAliasMode int8
const (
	NoAlias ExpandAliasMode = iota
	AliasBeforeColumn
	AliasAfterColumn
)

type Expr added in v0.5.0

type Expr = plan.Expr

func DeepCopyExpr added in v0.5.0

func DeepCopyExpr(expr *Expr) *Expr

func DeepCopyExprList added in v0.6.0

func DeepCopyExprList(list []*Expr) []*Expr

func GenUniqueColCheckExpr added in v0.8.0

func GenUniqueColCheckExpr(ctx context.Context, tableDef *TableDef, uniqueCols []map[string]int, colCount int) ([]*Expr, error)

GenUniqueColCheckExpr like GenUniqueColJoinExpr. but use for on duplicate key clause to check conflict if get table: t1(a int primary key, b int, c int, d int, unique key(b,c)); we get batch like [1,2,3,4, origin_a, origin_b, origin_c, origin_d, row_id ....]。 we get expr like: []*Expr{ 1=origin_a , (2 = origin_b and 3 = origin_c) }

func GenUniqueColJoinExpr added in v0.8.0

func GenUniqueColJoinExpr(ctx context.Context, tableDef *TableDef, uniqueCols []map[string]int, leftTag int32, rightTag int32) (*Expr, error)

GenUniqueColJoinExpr if get table: t1(a int primary key, b int, c int, d int, unique key(b,c)); uniqueCols is: []map[string]int { {'a'=1}, {'b'=2,'c'=3} } we will get expr like: 'leftTag.a = rightTag.a or (leftTag.b = rightTag.b and leftTag.c = rightTag. c)

func MakeFalseExpr added in v1.2.0

func MakeFalseExpr() *Expr

func MakeInExpr added in v1.2.0

func MakeInExpr(ctx context.Context, left *Expr, length int32, data []byte, matchPrefix bool) *Expr

func MakeIntervalExpr added in v1.2.0

func MakeIntervalExpr(num int64, str string) *Expr

func MakeSerialExtractExpr

func MakeSerialExtractExpr(ctx context.Context, fromExpr *Expr, origType Type, serialIdx int64) (*Expr, error)

type ExternAttr

type ExternAttr = plan.ExternAttr

type FkColName added in v0.8.0

type FkColName = plan.FkColName

type FkData added in v1.1.2

type FkData struct {
	// fk reference to itself
	IsSelfRefer bool
	// the database that the fk refers to
	ParentDbName string
	// the table that the fk refers to
	ParentTableName string
	// the columns in foreign key
	Cols *plan.FkColName
	// the columns referred
	ColsReferred *plan.FkColName
	// fk definition
	Def *plan.ForeignKeyDef
	// the column typs in foreign key
	ColTyps map[int]*plan.Type
	// update foreign keys relations
	UpdateSql string
	// forward reference
	ForwardRefer bool
}

type FkReferDef added in v1.1.2

type FkReferDef struct {
	Db       string //fk database name
	Tbl      string //fk table name
	Name     string //fk constraint name
	Col      string //fk column name, letter case: lower
	ReferCol string //referenced column name, letter case: lower
	OnDelete string //on delete action
	OnUpdate string //on update action
}

FkReferDef holds the definition & details of the foreign key

func (FkReferDef) String added in v1.1.2

func (fk FkReferDef) String() string

type FkReferKey added in v1.1.2

type FkReferKey struct {
	Db  string //fk database name
	Tbl string //fk table name
}

FkReferKey holds the database and table name of the foreign key

type ForeignKeyDef added in v0.7.0

type ForeignKeyDef = plan.ForeignKeyDef

func DeepCopyFkey added in v0.8.0

func DeepCopyFkey(fkey *ForeignKeyDef) *ForeignKeyDef

type FormatOption

type FormatOption struct {
	ExpandVec       bool
	ExpandVecMaxLen int

	// <=0 means no limit
	MaxDepth int
}

type GeneratedColBinder

type GeneratedColBinder struct {
	// contains filtered or unexported fields
}

GeneratedColBinder binds expressions for generated columns. Unlike DefaultBinder, it resolves each column reference with the column's own type instead of a single shared type.

func NewGeneratedColBinder

func NewGeneratedColBinder(sysCtx context.Context, colNames []string, colTypes []plan.Type) *GeneratedColBinder

func (*GeneratedColBinder) BindAggFunc

func (b *GeneratedColBinder) BindAggFunc(funcName string, astExpr *tree.FuncExpr, depth int32, isRoot bool) (*plan.Expr, error)

func (*GeneratedColBinder) BindColRef

func (b *GeneratedColBinder) BindColRef(astExpr *tree.UnresolvedName, _ int32, _ bool) (*plan.Expr, error)

func (*GeneratedColBinder) BindExpr

func (b *GeneratedColBinder) BindExpr(astExpr tree.Expr, depth int32, isRoot bool) (*plan.Expr, error)

func (*GeneratedColBinder) BindSubquery

func (b *GeneratedColBinder) BindSubquery(astExpr *tree.Subquery, isRoot bool) (*plan.Expr, error)

func (*GeneratedColBinder) BindTimeWindowFunc

func (b *GeneratedColBinder) BindTimeWindowFunc(funcName string, astExpr *tree.FuncExpr, depth int32, isRoot bool) (*plan.Expr, error)

func (*GeneratedColBinder) BindWinFunc

func (b *GeneratedColBinder) BindWinFunc(funcName string, astExpr *tree.FuncExpr, depth int32, isRoot bool) (*plan.Expr, error)

func (*GeneratedColBinder) GetContext

func (b *GeneratedColBinder) GetContext() context.Context

type GetParamRule added in v0.6.0

type GetParamRule struct {
	// contains filtered or unexported fields
}

func NewGetParamRule added in v0.5.1

func NewGetParamRule() *GetParamRule

func (*GetParamRule) ApplyExpr added in v0.6.0

func (rule *GetParamRule) ApplyExpr(e *plan.Expr) (*plan.Expr, error)

func (*GetParamRule) ApplyNode added in v0.6.0

func (rule *GetParamRule) ApplyNode(node *Node) error

func (*GetParamRule) IsApplyExpr added in v0.6.0

func (rule *GetParamRule) IsApplyExpr() bool

func (*GetParamRule) MatchNode added in v0.6.0

func (rule *GetParamRule) MatchNode(node *Node) bool

func (*GetParamRule) SetParamOrder added in v0.6.0

func (rule *GetParamRule) SetParamOrder()

type GroupBinder added in v0.5.0

type GroupBinder struct {
	// contains filtered or unexported fields
}

func NewGroupBinder added in v0.5.0

func NewGroupBinder(builder *QueryBuilder, ctx *BindContext, selectList tree.SelectExprs) *GroupBinder

func (*GroupBinder) BindAggFunc added in v0.5.0

func (b *GroupBinder) BindAggFunc(funcName string, astExpr *tree.FuncExpr, depth int32, isRoot bool) (*plan.Expr, error)

func (*GroupBinder) BindColRef added in v0.5.0

func (b *GroupBinder) BindColRef(astExpr *tree.UnresolvedName, depth int32, isRoot bool) (*plan.Expr, error)

func (*GroupBinder) BindExpr added in v0.5.0

func (b *GroupBinder) BindExpr(astExpr tree.Expr, depth int32, isRoot bool) (*plan.Expr, error)

func (*GroupBinder) BindSubquery added in v0.5.0

func (b *GroupBinder) BindSubquery(astExpr *tree.Subquery, isRoot bool) (*plan.Expr, error)

func (*GroupBinder) BindTimeWindowFunc added in v1.1.0

func (b *GroupBinder) BindTimeWindowFunc(funcName string, astExpr *tree.FuncExpr, depth int32, isRoot bool) (*plan.Expr, error)

func (*GroupBinder) BindWinFunc added in v0.5.0

func (b *GroupBinder) BindWinFunc(funcName string, astExpr *tree.FuncExpr, depth int32, isRoot bool) (*plan.Expr, error)

func (*GroupBinder) GetContext added in v0.7.0

func (b *GroupBinder) GetContext() context.Context

type HavingBinder added in v0.5.0

type HavingBinder struct {
	// contains filtered or unexported fields
}

func NewHavingBinder added in v0.5.0

func NewHavingBinder(builder *QueryBuilder, ctx *BindContext) *HavingBinder

func (*HavingBinder) BindAggFunc added in v0.5.0

func (b *HavingBinder) BindAggFunc(funcName string, astExpr *tree.FuncExpr, depth int32, isRoot bool) (*plan.Expr, error)

func (*HavingBinder) BindColRef added in v0.5.0

func (b *HavingBinder) BindColRef(astExpr *tree.UnresolvedName, depth int32, isRoot bool) (*plan.Expr, error)

func (*HavingBinder) BindExpr added in v0.5.0

func (b *HavingBinder) BindExpr(astExpr tree.Expr, depth int32, isRoot bool) (*plan.Expr, error)

func (*HavingBinder) BindSubquery added in v0.5.0

func (b *HavingBinder) BindSubquery(astExpr *tree.Subquery, isRoot bool) (*plan.Expr, error)

func (*HavingBinder) BindTimeWindowFunc added in v1.1.0

func (b *HavingBinder) BindTimeWindowFunc(funcName string, astExpr *tree.FuncExpr, depth int32, isRoot bool) (*plan.Expr, error)

func (*HavingBinder) BindWinFunc added in v0.5.0

func (b *HavingBinder) BindWinFunc(funcName string, astExpr *tree.FuncExpr, depth int32, isRoot bool) (*plan.Expr, error)

func (*HavingBinder) GetContext added in v0.7.0

func (b *HavingBinder) GetContext() context.Context

type IndexDef added in v0.6.0

type IndexDef = plan.IndexDef

type LimitBinder added in v0.5.0

type LimitBinder struct {
	// contains filtered or unexported fields
}

func NewLimitBinder added in v0.5.0

func NewLimitBinder(builder *QueryBuilder, ctx *BindContext, isOffset bool) *LimitBinder

func (*LimitBinder) BindAggFunc added in v0.5.0

func (b *LimitBinder) BindAggFunc(funcName string, astExpr *tree.FuncExpr, depth int32, isRoot bool) (*plan.Expr, error)

func (*LimitBinder) BindColRef added in v0.5.0

func (b *LimitBinder) BindColRef(astExpr *tree.UnresolvedName, depth int32, isRoot bool) (*plan.Expr, error)

func (*LimitBinder) BindExpr added in v0.5.0

func (b *LimitBinder) BindExpr(astExpr tree.Expr, depth int32, isRoot bool) (*plan.Expr, error)

func (*LimitBinder) BindSubquery added in v0.5.0

func (b *LimitBinder) BindSubquery(astExpr *tree.Subquery, isRoot bool) (*plan.Expr, error)

func (*LimitBinder) BindTimeWindowFunc added in v1.1.0

func (b *LimitBinder) BindTimeWindowFunc(funcName string, astExpr *tree.FuncExpr, depth int32, isRoot bool) (*plan.Expr, error)

func (*LimitBinder) BindWinFunc added in v0.5.0

func (b *LimitBinder) BindWinFunc(funcName string, astExpr *tree.FuncExpr, depth int32, isRoot bool) (*plan.Expr, error)

func (*LimitBinder) GetContext added in v0.7.0

func (b *LimitBinder) GetContext() context.Context

type MaxValue added in v0.6.0

type MaxValue = plan.MaxValue

type MoCacheColType added in v1.1.0

type MoCacheColType int32

type MoConfigColType added in v1.1.0

type MoConfigColType int32

type MoLocksColType added in v1.1.0

type MoLocksColType int32

type MoTransactionsColType added in v1.1.0

type MoTransactionsColType int32

type MockCompilerContext added in v0.5.0

type MockCompilerContext struct {

	// Add function fields for test overrides
	GetAccountNameFunc    func() string
	GetAccountIdFunc      func() (uint32, error)
	DatabaseExistsFunc    func(string, *Snapshot) bool
	GetDatabaseIdFunc     func(string, *Snapshot) (uint64, error)
	ResolveAccountIdsFunc func([]string) ([]uint32, error)
	ResolveFunc           func(string, string, *Snapshot) (*ObjectRef, *TableDef)
	// contains filtered or unexported fields
}

func NewEmptyCompilerContext added in v0.5.0

func NewEmptyCompilerContext() *MockCompilerContext

NewEmptyCompilerContext for test create/drop statement

func NewMockCompilerContext added in v0.5.0

func NewMockCompilerContext(isDml bool) *MockCompilerContext

func (*MockCompilerContext) BuildTableDefByMoColumns

func (m *MockCompilerContext) BuildTableDefByMoColumns(dbName, table string) (*TableDef, error)

func (*MockCompilerContext) CheckSubscriptionValid added in v0.8.0

func (m *MockCompilerContext) CheckSubscriptionValid(subName, accName string, pubName string) error

func (*MockCompilerContext) CheckTimeStampValid added in v1.2.0

func (m *MockCompilerContext) CheckTimeStampValid(ts int64) (bool, error)

func (*MockCompilerContext) DatabaseExists added in v0.5.0

func (m *MockCompilerContext) DatabaseExists(name string, snapshot *Snapshot) bool

func (*MockCompilerContext) DefaultDatabase added in v0.5.0

func (m *MockCompilerContext) DefaultDatabase() string

func (*MockCompilerContext) GetAccountId added in v0.6.0

func (m *MockCompilerContext) GetAccountId() (uint32, error)

func (*MockCompilerContext) GetAccountName

func (m *MockCompilerContext) GetAccountName() string

func (*MockCompilerContext) GetBuildingAlterView added in v0.7.0

func (m *MockCompilerContext) GetBuildingAlterView() (bool, string, string)

func (*MockCompilerContext) GetContext added in v0.7.0

func (m *MockCompilerContext) GetContext() context.Context

func (*MockCompilerContext) GetDatabaseId added in v0.8.0

func (m *MockCompilerContext) GetDatabaseId(dbName string, snapshot *Snapshot) (uint64, error)

func (*MockCompilerContext) GetLowerCaseTableNames added in v1.2.1

func (m *MockCompilerContext) GetLowerCaseTableNames() int64

func (*MockCompilerContext) GetProcess added in v0.7.0

func (m *MockCompilerContext) GetProcess() *process.Process

func (*MockCompilerContext) GetQueryResultMeta added in v0.7.0

func (m *MockCompilerContext) GetQueryResultMeta(uuid string) ([]*ColDef, string, error)

func (*MockCompilerContext) GetQueryingSubscription added in v0.8.0

func (m *MockCompilerContext) GetQueryingSubscription() *SubscriptionMeta

func (*MockCompilerContext) GetRootSql added in v0.6.0

func (m *MockCompilerContext) GetRootSql() string

func (*MockCompilerContext) GetSnapshot added in v1.2.0

func (m *MockCompilerContext) GetSnapshot() *Snapshot

func (*MockCompilerContext) GetStatsCache added in v0.8.0

func (m *MockCompilerContext) GetStatsCache() *StatsCache

func (*MockCompilerContext) GetSubscriptionMeta added in v0.8.0

func (m *MockCompilerContext) GetSubscriptionMeta(dbName string, snapshot *Snapshot) (*SubscriptionMeta, error)

func (*MockCompilerContext) GetUserName added in v0.6.0

func (m *MockCompilerContext) GetUserName() string

func (*MockCompilerContext) GetViews added in v1.2.0

func (m *MockCompilerContext) GetViews() []string

func (*MockCompilerContext) InitExecuteStmtParam

func (m *MockCompilerContext) InitExecuteStmtParam(execPlan *plan.Execute) (*plan.Plan, tree.Statement, error)

func (*MockCompilerContext) IsPublishing added in v0.8.0

func (m *MockCompilerContext) IsPublishing(dbName string) (bool, error)

func (*MockCompilerContext) Resolve added in v0.5.0

func (m *MockCompilerContext) Resolve(dbName string, tableName string, snapshot *Snapshot) (*ObjectRef, *TableDef, error)

func (*MockCompilerContext) ResolveAccountIds added in v0.7.0

func (m *MockCompilerContext) ResolveAccountIds(accountNames []string) ([]uint32, error)

func (*MockCompilerContext) ResolveById added in v0.7.0

func (m *MockCompilerContext) ResolveById(tableId uint64, snapshot *Snapshot) (*ObjectRef, *TableDef, error)

func (*MockCompilerContext) ResolveIndexTableByRef

func (m *MockCompilerContext) ResolveIndexTableByRef(ref *ObjectRef, tblName string, snapshot *Snapshot) (*ObjectRef, *TableDef, error)

func (*MockCompilerContext) ResolveSnapshotWithSnapshotName added in v1.2.0

func (m *MockCompilerContext) ResolveSnapshotWithSnapshotName(snapshotName string) (*Snapshot, error)

func (*MockCompilerContext) ResolveSubscriptionTableById added in v1.2.0

func (m *MockCompilerContext) ResolveSubscriptionTableById(tableId uint64, pubmeta *SubscriptionMeta) (*ObjectRef, *TableDef, error)

func (*MockCompilerContext) ResolveUdf added in v0.8.0

func (m *MockCompilerContext) ResolveUdf(name string, ast []*plan.Expr) (*function.Udf, error)

func (*MockCompilerContext) ResolveVariable added in v0.5.0

func (m *MockCompilerContext) ResolveVariable(varName string, isSystemVar, isGlobalVar bool) (interface{}, error)

func (*MockCompilerContext) SetBuildingAlterView added in v0.7.0

func (m *MockCompilerContext) SetBuildingAlterView(yesOrNo bool, dbName, viewName string)

func (*MockCompilerContext) SetContext

func (m *MockCompilerContext) SetContext(ctx context.Context)

func (*MockCompilerContext) SetQueryingSubscription added in v0.8.0

func (m *MockCompilerContext) SetQueryingSubscription(*SubscriptionMeta)

func (*MockCompilerContext) SetSnapshot added in v1.2.0

func (m *MockCompilerContext) SetSnapshot(snapshot *Snapshot)

func (*MockCompilerContext) SetViews added in v1.2.0

func (m *MockCompilerContext) SetViews(views []string)

func (*MockCompilerContext) Stats added in v0.7.0

func (m *MockCompilerContext) Stats(obj *ObjectRef, snapshot *Snapshot) (*pb.StatsInfo, error)

type MockOptimizer added in v0.5.0

type MockOptimizer struct {
	// contains filtered or unexported fields
}

func NewEmptyMockOptimizer added in v0.5.0

func NewEmptyMockOptimizer() *MockOptimizer

func NewMockOptimizer added in v0.5.0

func NewMockOptimizer(_ bool) *MockOptimizer

func (*MockOptimizer) CurrentContext added in v0.5.0

func (moc *MockOptimizer) CurrentContext() CompilerContext

func (*MockOptimizer) Optimize added in v0.5.0

func (moc *MockOptimizer) Optimize(stmt tree.Statement) (*Query, error)

type MultiTableIndex added in v1.1.0

type MultiTableIndex struct {
	IndexAlgo       string
	IndexAlgoParams string
	IndexDefs       map[string]*plan.IndexDef
}

type NameTuple added in v0.5.0

type NameTuple struct {
	// contains filtered or unexported fields
}

type Node added in v0.5.0

type Node = plan.Node

type ObjectRef added in v0.5.0

type ObjectRef = plan.ObjectRef

type OndupUpdateBinder

type OndupUpdateBinder struct {
	// contains filtered or unexported fields
}

func NewOndupUpdateBinder

func NewOndupUpdateBinder(sysCtx context.Context, builder *QueryBuilder, ctx *BindContext, scanTag, selectTag int32, tableDef *plan.TableDef) *OndupUpdateBinder

use for on duplicate key update clause: eg: insert into t1 values(1,1),(2,2) on duplicate key update a = a + abs(b), b = values(b)-2

func (*OndupUpdateBinder) BindAggFunc

func (b *OndupUpdateBinder) BindAggFunc(funcName string, astExpr *tree.FuncExpr, depth int32, isRoot bool) (*plan.Expr, error)

func (*OndupUpdateBinder) BindColRef

func (b *OndupUpdateBinder) BindColRef(astExpr *tree.UnresolvedName, depth int32, isRoot bool) (*plan.Expr, error)

func (*OndupUpdateBinder) BindExpr

func (b *OndupUpdateBinder) BindExpr(astExpr tree.Expr, depth int32, isRoot bool) (*plan.Expr, error)

func (*OndupUpdateBinder) BindSubquery

func (b *OndupUpdateBinder) BindSubquery(astExpr *tree.Subquery, isRoot bool) (*plan.Expr, error)

func (*OndupUpdateBinder) BindTimeWindowFunc

func (b *OndupUpdateBinder) BindTimeWindowFunc(funcName string, astExpr *tree.FuncExpr, depth int32, isRoot bool) (*plan.Expr, error)

func (*OndupUpdateBinder) BindWinFunc

func (b *OndupUpdateBinder) BindWinFunc(funcName string, astExpr *tree.FuncExpr, depth int32, isRoot bool) (*plan.Expr, error)

func (*OndupUpdateBinder) GetContext

func (b *OndupUpdateBinder) GetContext() context.Context

type Optimizer added in v0.5.0

type Optimizer interface {
	Optimize(stmt tree.Statement) (*Query, error)
	CurrentContext() CompilerContext
}

type OptimizerHints added in v1.2.0

type OptimizerHints struct {
	// contains filtered or unexported fields
}

type OrderBinder added in v0.5.0

type OrderBinder struct {
	*ProjectionBinder
	// contains filtered or unexported fields
}

func NewOrderBinder added in v0.5.0

func NewOrderBinder(projectionBinder *ProjectionBinder, selectList tree.SelectExprs) *OrderBinder

func (*OrderBinder) BindExpr added in v0.5.0

func (b *OrderBinder) BindExpr(astExpr tree.Expr) (*plan.Expr, error)

func (OrderBinder) GetContext added in v0.7.0

func (b OrderBinder) GetContext() context.Context

type OrderBySpec added in v0.6.0

type OrderBySpec = plan.OrderBySpec

type OriginTableMessageForFuzzy added in v1.1.0

type OriginTableMessageForFuzzy struct {
	ParentTableName  string
	ParentUniqueCols []*ColDef
}

fuzzy filter need to get partial unique key attrs name and its origin table name for Decimal type, we need colDef to get the scale

type ParseJsonlOptions

type ParseJsonlOptions struct {
	Format string                 `json:"format"`
	Cols   []ParseJsonlOptionsCol `json:"cols"`
}

type ParseJsonlOptionsCol

type ParseJsonlOptionsCol struct {
	Name string `json:"name"`
	Type string `json:"type"`
}

type PartitionBinder added in v0.6.0

type PartitionBinder struct {
	// contains filtered or unexported fields
}

func NewPartitionBinder added in v0.6.0

func NewPartitionBinder(builder *QueryBuilder, ctx *BindContext) *PartitionBinder

func (*PartitionBinder) BindAggFunc added in v0.6.0

func (p *PartitionBinder) BindAggFunc(funcName string, astExpr *tree.FuncExpr, depth int32, isRoot bool) (*plan.Expr, error)

func (*PartitionBinder) BindColRef added in v0.6.0

func (p *PartitionBinder) BindColRef(astExpr *tree.UnresolvedName, depth int32, isRoot bool) (*plan.Expr, error)

func (*PartitionBinder) BindExpr added in v0.6.0

func (p *PartitionBinder) BindExpr(astExpr tree.Expr, depth int32, isRoot bool) (*plan.Expr, error)

func (*PartitionBinder) BindSubquery added in v0.6.0

func (p *PartitionBinder) BindSubquery(astExpr *tree.Subquery, isRoot bool) (*plan.Expr, error)

func (*PartitionBinder) BindTimeWindowFunc added in v1.1.0

func (p *PartitionBinder) BindTimeWindowFunc(funcName string, astExpr *tree.FuncExpr, depth int32, isRoot bool) (*plan.Expr, error)

func (*PartitionBinder) BindWinFunc added in v0.6.0

func (p *PartitionBinder) BindWinFunc(funcName string, astExpr *tree.FuncExpr, depth int32, isRoot bool) (*plan.Expr, error)

func (*PartitionBinder) GetContext added in v0.7.0

func (b *PartitionBinder) GetContext() context.Context

type Plan

type Plan = plan.Plan

func BuildPlan added in v0.5.0

func BuildPlan(ctx CompilerContext, stmt tree.Statement, isPrepareStmt bool) (*Plan, error)

func DeepCopyPlan added in v0.6.0

func DeepCopyPlan(pl *Plan) *Plan

func FillValuesOfParamsInPlan added in v1.2.0

func FillValuesOfParamsInPlan(ctx context.Context, preparePlan *Plan, paramVals []any) (*Plan, error)

FillValuesOfParamsInPlan replaces the params by their values

type Plan_Query added in v0.5.0

type Plan_Query = plan.Plan_Query

type PrimaryKeyDef added in v0.7.0

type PrimaryKeyDef = plan.PrimaryKeyDef

type ProjectionBinder added in v0.5.0

type ProjectionBinder struct {
	// contains filtered or unexported fields
}

func NewProjectionBinder added in v0.5.0

func NewProjectionBinder(builder *QueryBuilder, ctx *BindContext, havingBinder *HavingBinder) *ProjectionBinder

func (*ProjectionBinder) BindAggFunc added in v0.5.0

func (b *ProjectionBinder) BindAggFunc(funcName string, astExpr *tree.FuncExpr, depth int32, isRoot bool) (*plan.Expr, error)

func (*ProjectionBinder) BindColRef added in v0.5.0

func (b *ProjectionBinder) BindColRef(astExpr *tree.UnresolvedName, depth int32, isRoot bool) (*plan.Expr, error)

func (*ProjectionBinder) BindExpr added in v0.5.0

func (b *ProjectionBinder) BindExpr(astExpr tree.Expr, depth int32, isRoot bool) (*plan.Expr, error)

func (*ProjectionBinder) BindSubquery added in v0.5.0

func (b *ProjectionBinder) BindSubquery(astExpr *tree.Subquery, isRoot bool) (*plan.Expr, error)

func (*ProjectionBinder) BindTimeWindowFunc added in v1.1.0

func (b *ProjectionBinder) BindTimeWindowFunc(funcName string, astExpr *tree.FuncExpr, depth int32, isRoot bool) (*plan.Expr, error)

func (*ProjectionBinder) BindWinFunc added in v0.5.0

func (b *ProjectionBinder) BindWinFunc(funcName string, astExpr *tree.FuncExpr, depth int32, isRoot bool) (*plan.Expr, error)

func (*ProjectionBinder) GetContext added in v0.7.0

func (b *ProjectionBinder) GetContext() context.Context

type PropertiesDef added in v0.6.0

type PropertiesDef = plan.PropertiesDef

type Property added in v0.6.0

type Property = plan.Property

type Query

type Query = plan.Query

type QueryBuilder added in v0.5.0

type QueryBuilder struct {
	// contains filtered or unexported fields
}

func NewQueryBuilder added in v0.5.0

func NewQueryBuilder(queryType plan.Query_StatementType, ctx CompilerContext, isPrepareStatement bool, skipStats bool) *QueryBuilder

func (*QueryBuilder) AppendNode

func (builder *QueryBuilder) AppendNode(node *plan.Node, ctx planplugin.BindContext) int32

func (*QueryBuilder) ApplyIndicesForSortUsingCagra

func (builder *QueryBuilder) ApplyIndicesForSortUsingCagra(vctx *planplugin.VectorSortContext, mti *planplugin.MultiTableIndexRef, nodeID int32, _ planplugin.ApplyForSortOpts) (int32, bool, error)

func (*QueryBuilder) ApplyIndicesForSortUsingHnsw

func (builder *QueryBuilder) ApplyIndicesForSortUsingHnsw(vctx *planplugin.VectorSortContext, mti *planplugin.MultiTableIndexRef, nodeID int32, _ planplugin.ApplyForSortOpts) (int32, bool, error)

func (*QueryBuilder) ApplyIndicesForSortUsingIvfflat

func (builder *QueryBuilder) ApplyIndicesForSortUsingIvfflat(vctx *planplugin.VectorSortContext, mti *planplugin.MultiTableIndexRef, nodeID int32, opts planplugin.ApplyForSortOpts) (int32, bool, error)

func (*QueryBuilder) ApplyIndicesForSortUsingIvfpq

func (builder *QueryBuilder) ApplyIndicesForSortUsingIvfpq(vctx *planplugin.VectorSortContext, mti *planplugin.MultiTableIndexRef, nodeID int32, _ planplugin.ApplyForSortOpts) (int32, bool, error)

func (*QueryBuilder) CanApplyCagra

func (builder *QueryBuilder) CanApplyCagra(vctx *planplugin.VectorSortContext, mti *planplugin.MultiTableIndexRef) (bool, error)

func (*QueryBuilder) CanApplyHnsw

func (builder *QueryBuilder) CanApplyHnsw(vctx *planplugin.VectorSortContext, mti *planplugin.MultiTableIndexRef) (bool, error)

func (*QueryBuilder) CanApplyIvfflat

func (builder *QueryBuilder) CanApplyIvfflat(vctx *planplugin.VectorSortContext, mti *planplugin.MultiTableIndexRef) (bool, error)

func (*QueryBuilder) CanApplyIvfpq

func (builder *QueryBuilder) CanApplyIvfpq(vctx *planplugin.VectorSortContext, mti *planplugin.MultiTableIndexRef) (bool, error)

func (*QueryBuilder) GenNewBindTag

func (builder *QueryBuilder) GenNewBindTag() int32

func (*QueryBuilder) GetContext added in v0.7.0

func (builder *QueryBuilder) GetContext() context.Context

func (*QueryBuilder) IsEquiJoin added in v0.8.0

func (builder *QueryBuilder) IsEquiJoin(node *plan.Node) bool

func (*QueryBuilder) ResolveTsHint

func (builder *QueryBuilder) ResolveTsHint(tsExpr *tree.AtTimeStamp) (snapshot *Snapshot, err error)

type RemapInfo added in v1.2.2

type RemapInfo struct {
	// contains filtered or unexported fields
}

func (*RemapInfo) String added in v1.2.2

func (info *RemapInfo) String() string

type ResetParamOrderRule added in v0.6.0

type ResetParamOrderRule struct {
	// contains filtered or unexported fields
}

func NewResetParamOrderRule added in v0.6.0

func NewResetParamOrderRule(params map[int]int) *ResetParamOrderRule

func (*ResetParamOrderRule) ApplyExpr added in v0.6.0

func (rule *ResetParamOrderRule) ApplyExpr(e *plan.Expr) (*plan.Expr, error)

func (*ResetParamOrderRule) ApplyNode added in v0.6.0

func (rule *ResetParamOrderRule) ApplyNode(node *Node) error

func (*ResetParamOrderRule) IsApplyExpr added in v0.6.0

func (rule *ResetParamOrderRule) IsApplyExpr() bool

func (*ResetParamOrderRule) MatchNode added in v0.6.0

func (rule *ResetParamOrderRule) MatchNode(_ *Node) bool

type ResetParamRefRule added in v0.6.0

type ResetParamRefRule struct {
	// contains filtered or unexported fields
}

func NewResetParamRefRule added in v0.6.0

func NewResetParamRefRule(ctx context.Context, params []*Expr) *ResetParamRefRule

func (*ResetParamRefRule) ApplyExpr added in v0.6.0

func (rule *ResetParamRefRule) ApplyExpr(e *plan.Expr) (*plan.Expr, error)

func (*ResetParamRefRule) ApplyNode added in v0.6.0

func (rule *ResetParamRefRule) ApplyNode(node *Node) error

func (*ResetParamRefRule) IsApplyExpr added in v0.6.0

func (rule *ResetParamRefRule) IsApplyExpr() bool

func (*ResetParamRefRule) MatchNode added in v0.6.0

func (rule *ResetParamRefRule) MatchNode(_ *Node) bool

type RowsetData added in v0.5.0

type RowsetData = plan.RowsetData

type Rule added in v0.5.0

type Rule interface {
	Match(*Node) bool                      // rule match?
	Apply(*Node, *Query, *process.Process) // apply the rule
}

type SampleFuncCtx added in v1.1.0

type SampleFuncCtx struct {
	// contains filtered or unexported fields
}

func (*SampleFuncCtx) BindSampleColumn added in v1.1.0

func (s *SampleFuncCtx) BindSampleColumn(ctx *BindContext, binder *ProjectionBinder, sampleList tree.SelectExprs) ([]*plan.Expr, error)

func (*SampleFuncCtx) GenerateSampleFunc added in v1.1.0

func (s *SampleFuncCtx) GenerateSampleFunc(se *tree.SampleExpr) error

func (*SampleFuncCtx) SetStartOffset added in v1.1.0

func (s *SampleFuncCtx) SetStartOffset(start, offset int)

type Schema added in v0.5.0

type Schema struct {
	// contains filtered or unexported fields
}

type SelectField

type SelectField struct {
	// contains filtered or unexported fields
}

type SetBinder added in v0.8.0

type SetBinder struct {
	// contains filtered or unexported fields
}

SetBinder for 'set @var = expr'

func NewSetVarBinder added in v0.8.0

func NewSetVarBinder(builder *QueryBuilder, ctx *BindContext) *SetBinder

func (*SetBinder) BindAggFunc added in v0.8.0

func (s *SetBinder) BindAggFunc(_ string, expr *tree.FuncExpr, i int32, b bool) (*plan.Expr, error)

func (*SetBinder) BindColRef added in v0.8.0

func (s *SetBinder) BindColRef(name *tree.UnresolvedName, i int32, b bool) (*plan.Expr, error)

func (*SetBinder) BindExpr added in v0.8.0

func (s *SetBinder) BindExpr(expr tree.Expr, i int32, b bool) (*plan.Expr, error)

BindExpr prohibits functions in set expr

func (*SetBinder) BindSubquery added in v0.8.0

func (s *SetBinder) BindSubquery(subquery *tree.Subquery, b bool) (*plan.Expr, error)

func (*SetBinder) BindTimeWindowFunc added in v1.1.0

func (s *SetBinder) BindTimeWindowFunc(funcName string, astExpr *tree.FuncExpr, depth int32, isRoot bool) (*plan.Expr, error)

func (*SetBinder) BindWinFunc added in v0.8.0

func (s *SetBinder) BindWinFunc(_ string, expr *tree.FuncExpr, i int32, b bool) (*plan.Expr, error)

func (*SetBinder) GetContext added in v0.8.0

func (b *SetBinder) GetContext() context.Context

type Snapshot added in v1.2.0

type Snapshot = plan.Snapshot

type SnapshotTenant added in v1.2.0

type SnapshotTenant = plan.SnapshotTenant

type Stats added in v0.7.0

type Stats = plan.Stats

type StatsCache added in v0.8.0

type StatsCache struct {
	// contains filtered or unexported fields
}

func NewStatsCache added in v0.8.0

func NewStatsCache() *StatsCache

func (*StatsCache) Get

func (sc *StatsCache) Get(tableID uint64) StatsInfoWrapper

Get returns the cached wrapper for the table. Use wrapper.Exists() to check if it was actually cached.

func (*StatsCache) Set

func (sc *StatsCache) Set(tableID uint64, stats *pb.StatsInfo)

Set caches the stats result for the table.

type StatsInfoWrapper

type StatsInfoWrapper struct {
	// contains filtered or unexported fields
}

The StatsInfoWrapper caches the stats query result for a table.

func (*StatsInfoWrapper) Exists

func (w *StatsInfoWrapper) Exists() bool

Exists returns true if the wrapper has been set (lastVisit > 0).

func (*StatsInfoWrapper) GetLastVisit

func (w *StatsInfoWrapper) GetLastVisit() int64

GetLastVisit returns the last visit time (unix seconds).

func (*StatsInfoWrapper) GetStats

func (w *StatsInfoWrapper) GetStats() *pb.StatsInfo

GetStats returns the cached stats.

type SubscriptionMeta added in v0.8.0

type SubscriptionMeta = plan.SubscriptionMeta

type TableBinder added in v0.5.0

type TableBinder struct {
	// contains filtered or unexported fields
}

func NewTableBinder added in v0.5.0

func NewTableBinder(builder *QueryBuilder, ctx *BindContext) *TableBinder

func (*TableBinder) BindAggFunc added in v0.5.0

func (b *TableBinder) BindAggFunc(funcName string, astExpr *tree.FuncExpr, depth int32, isRoot bool) (*plan.Expr, error)

func (*TableBinder) BindColRef added in v0.5.0

func (b *TableBinder) BindColRef(astExpr *tree.UnresolvedName, depth int32, isRoot bool) (*plan.Expr, error)

func (*TableBinder) BindExpr added in v0.5.0

func (b *TableBinder) BindExpr(astExpr tree.Expr, depth int32, isRoot bool) (*plan.Expr, error)

func (*TableBinder) BindSubquery added in v0.5.0

func (b *TableBinder) BindSubquery(astExpr *tree.Subquery, isRoot bool) (*plan.Expr, error)

func (*TableBinder) BindTimeWindowFunc added in v1.1.0

func (b *TableBinder) BindTimeWindowFunc(funcName string, astExpr *tree.FuncExpr, depth int32, isRoot bool) (*plan.Expr, error)

func (*TableBinder) BindWinFunc added in v0.5.0

func (b *TableBinder) BindWinFunc(funcName string, astExpr *tree.FuncExpr, depth int32, isRoot bool) (*plan.Expr, error)

func (*TableBinder) GetContext added in v0.7.0

func (b *TableBinder) GetContext() context.Context

type TableDef added in v0.5.0

type TableDef = plan.TableDef

type TableDefType added in v0.6.0

type TableDefType = plan.TableDef_DefType

type TableDef_DefType_Properties added in v0.6.0

type TableDef_DefType_Properties = plan.TableDef_DefType_Properties

type TableStatsInfo

type TableStatsInfo struct {
	ColumnZMs            []objectio.ZoneMap
	DataTypes            []types.Type
	ColumnNDVs           []float64
	MaxNDVs              []float64
	NDVinMaxObject       []float64 // NDV in the object with maximum row count, per column
	NDVinMinObject       []float64 // NDV in the object with minimum row count, per column
	NullCnts             []int64
	ShuffleRanges        []*pb.ShuffleRange
	ColumnSize           []int64
	MaxObjectRowCount    uint32 // Maximum row count among all objects in the table
	MinObjectRowCount    uint32 // Minimum row count among all objects in the table
	BlockNumber          int64
	AccurateObjectNumber int64
	ApproxObjectNumber   int64
	TableRowCount        float64 // Total row count in the table
}

func NewTableStatsInfo

func NewTableStatsInfo(lenCols int) *TableStatsInfo

type Type added in v0.5.0

type Type = plan.Type

type UnorderedSet added in v1.2.1

type UnorderedSet[T ~string | ~int] map[T]int

func (UnorderedSet[T]) Find added in v1.2.1

func (set UnorderedSet[T]) Find(val T) bool

func (UnorderedSet[T]) Insert added in v1.2.1

func (set UnorderedSet[T]) Insert(val T)

type UpdateBinder added in v0.8.0

type UpdateBinder struct {
	// contains filtered or unexported fields
}

func NewUpdateBinder added in v0.8.0

func NewUpdateBinder(sysCtx context.Context, builder *QueryBuilder, ctx *BindContext, cols []*ColDef) *UpdateBinder

use for on duplicate key update clause: eg: insert into t1 values(1,1),(2,2) on duplicate key update a = a + abs(b), b = values(b)-2

func (*UpdateBinder) BindAggFunc added in v0.8.0

func (b *UpdateBinder) BindAggFunc(funcName string, astExpr *tree.FuncExpr, depth int32, isRoot bool) (*plan.Expr, error)

func (*UpdateBinder) BindColRef added in v0.8.0

func (b *UpdateBinder) BindColRef(astExpr *tree.UnresolvedName, depth int32, isRoot bool) (*plan.Expr, error)

func (*UpdateBinder) BindExpr added in v0.8.0

func (b *UpdateBinder) BindExpr(astExpr tree.Expr, depth int32, isRoot bool) (*plan.Expr, error)

func (*UpdateBinder) BindSubquery added in v0.8.0

func (b *UpdateBinder) BindSubquery(astExpr *tree.Subquery, isRoot bool) (*plan.Expr, error)

func (*UpdateBinder) BindTimeWindowFunc added in v1.1.0

func (b *UpdateBinder) BindTimeWindowFunc(funcName string, astExpr *tree.FuncExpr, depth int32, isRoot bool) (*plan.Expr, error)

func (*UpdateBinder) BindWinFunc added in v0.8.0

func (b *UpdateBinder) BindWinFunc(funcName string, astExpr *tree.FuncExpr, depth int32, isRoot bool) (*plan.Expr, error)

func (*UpdateBinder) GetContext added in v0.8.0

func (b *UpdateBinder) GetContext() context.Context

type ViewCfg

type ViewCfg struct {
	// contains filtered or unexported fields
}

type ViewData added in v0.6.0

type ViewData struct {
	Stmt            string
	DefaultDatabase string
	SecurityType    string `json:"security_type,omitempty"`
}

type ViewDef added in v0.6.0

type ViewDef = plan.ViewDef

type VisitPlan added in v0.6.0

type VisitPlan struct {
	// contains filtered or unexported fields
}

func NewVisitPlan added in v0.6.0

func NewVisitPlan(pl *Plan, rules []VisitPlanRule) *VisitPlan

func (*VisitPlan) Visit added in v0.6.0

func (vq *VisitPlan) Visit(ctx context.Context) error

type VisitPlanRule added in v0.6.0

type VisitPlanRule interface {
	MatchNode(*Node) bool
	IsApplyExpr() bool
	ApplyNode(*Node) error
	ApplyExpr(*Expr) (*Expr, error)
}

type WhereBinder added in v0.5.0

type WhereBinder struct {
	// contains filtered or unexported fields
}

func NewWhereBinder added in v0.5.0

func NewWhereBinder(builder *QueryBuilder, ctx *BindContext) *WhereBinder

func (*WhereBinder) BindAggFunc added in v0.5.0

func (b *WhereBinder) BindAggFunc(funcName string, astExpr *tree.FuncExpr, depth int32, isRoot bool) (*plan.Expr, error)

func (*WhereBinder) BindColRef added in v0.5.0

func (b *WhereBinder) BindColRef(astExpr *tree.UnresolvedName, depth int32, isRoot bool) (*plan.Expr, error)

func (*WhereBinder) BindExpr added in v0.5.0

func (b *WhereBinder) BindExpr(astExpr tree.Expr, depth int32, isRoot bool) (*plan.Expr, error)

func (*WhereBinder) BindSubquery added in v0.5.0

func (b *WhereBinder) BindSubquery(astExpr *tree.Subquery, isRoot bool) (*plan.Expr, error)

func (*WhereBinder) BindTimeWindowFunc added in v1.1.0

func (b *WhereBinder) BindTimeWindowFunc(funcName string, astExpr *tree.FuncExpr, depth int32, isRoot bool) (*plan.Expr, error)

func (*WhereBinder) BindWinFunc added in v0.5.0

func (b *WhereBinder) BindWinFunc(funcName string, astExpr *tree.FuncExpr, depth int32, isRoot bool) (*plan.Expr, error)

func (*WhereBinder) GetContext added in v0.7.0

func (b *WhereBinder) GetContext() context.Context

Source Files

Directories

Path Synopsis
ctl

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL