Documentation
¶
Index ¶
- Constants
- Variables
- func BuildHivePartitionListCacheKey(param *tree.ExternParam, accountID uint32, basePath, prefix string) string
- func BuildHivePartitionListCacheKeyPrefix(param *tree.ExternParam, accountID uint32, basePath string) string
- func ClassifyFilters(tableDef *plan.TableDef, filters []*plan.Expr, partColSet map[string]bool) (partitionFilters, filePathFilters, rowFilters []*plan.Expr)
- func ExtractPartitionValues(filePath, basePath string, partCols []string) (map[string]string, error)
- func FilterFileList(ctx context.Context, node *plan.Node, proc *process.Process, fileList []string, ...) ([]string, []int64, error)
- func IsHiddenFile(name string) bool
- func IsParquetFile(name string) bool
- func ReadFileOffset(param *tree.ExternParam, mcpu int, fileSize int64, visibleCols []*plan.ColDef) ([]int64, error)
- func ResetHivePartitionListCacheForTest()
- type CsvReader
- type DiscoverOptions
- type ExFileparam
- type ExParam
- type ExParamConst
- type External
- func (external *External) Call(proc *process.Process) (vm.CallResult, error)
- func (external *External) ExecProjection(proc *process.Process, input *batch.Batch) (*batch.Batch, error)
- func (external *External) Free(proc *process.Process, pipelineFailed bool, err error)
- func (external *External) GetOperatorBase() *vm.OperatorBase
- func (external *External) OpType() vm.OpType
- func (external *External) Prepare(proc *process.Process) error
- func (external *External) Release()
- func (external *External) Reset(proc *process.Process, pipelineFailed bool, err error)
- func (external *External) String(buf *bytes.Buffer)
- func (external External) TypeName() string
- func (external *External) WithEs(es *ExternalParam) *External
- type ExternalFileReader
- type ExternalParam
- type FilterParam
- type HivePartSegment
- type HivePartitionListCacheEntry
- type ListDirFunc
- type MatchResult
- type ParquetHandler
- type ParquetReader
- type ParseLineHandler
- type PartitionAnd
- type PartitionAtom
- type PartitionDiscoveryResult
- func DiscoverHivePartitions(ctx context.Context, listDir ListDirFunc, basePath string, partCols []string, ...) (*PartitionDiscoveryResult, error)
- func DiscoverHivePartitionsWithPruneExpr(ctx context.Context, listDir ListDirFunc, basePath string, partCols []string, ...) (*PartitionDiscoveryResult, error)
- type PartitionFileEntry
- type PartitionOp
- type PartitionOr
- type PartitionPredicate
- type PartitionPruneExpr
- type ZonemapFileparam
- type ZonemapReader
Constants ¶
const (
ColumnCntLargerErrorInfo = "the table column is larger than input data column"
)
const (
HiveDefaultPartition = "__HIVE_DEFAULT_PARTITION__"
)
const JsonNull = "\\N"
Variables ¶
var ( OneBatchMaxRow = int(options.DefaultBlockMaxRows) S3ParallelMaxnum = 10 )
var (
STATEMENT_ACCOUNT = "account"
)
Functions ¶
func BuildHivePartitionListCacheKey ¶
func BuildHivePartitionListCacheKey(param *tree.ExternParam, accountID uint32, basePath, prefix string) string
func BuildHivePartitionListCacheKeyPrefix ¶
func BuildHivePartitionListCacheKeyPrefix(param *tree.ExternParam, accountID uint32, basePath string) string
func ClassifyFilters ¶
func ClassifyFilters( tableDef *plan.TableDef, filters []*plan.Expr, partColSet map[string]bool, ) (partitionFilters, filePathFilters, rowFilters []*plan.Expr)
ClassifyFilters splits a filter list into three disjoint groups:
- partitionFilters: only reference partition columns (also copied to rowFilters)
- filePathFilters: only reference filepath virtual columns (see filePathColSet: __mo_filepath only)
- rowFilters: everything else, plus partition filters for double-filtering safety
func ExtractPartitionValues ¶
func ExtractPartitionValues(filePath, basePath string, partCols []string) (map[string]string, error)
ExtractPartitionValues parses partition key=value segments from a file path relative to basePath. Both paths are normalized internally.
func FilterFileList ¶ added in v0.7.0
func IsHiddenFile ¶
IsHiddenFile returns true for files/dirs starting with '.' or '_'.
func IsParquetFile ¶
IsParquetFile returns true for files with .parquet or .snappy.parquet suffix.
func ReadFileOffset ¶ added in v0.7.0
func ResetHivePartitionListCacheForTest ¶
func ResetHivePartitionListCacheForTest()
Types ¶
type CsvReader ¶
type CsvReader struct {
// contains filtered or unexported fields
}
CsvReader handles CSV and JSONLINE formats.
func NewCsvReader ¶
func NewCsvReader(param *ExternalParam, proc *process.Process) (*CsvReader, error)
NewCsvReader creates a CsvReader. JSONLINE invalid config returns explicit error to match existing semantics.
type DiscoverOptions ¶
type ExFileparam ¶ added in v0.7.0
type ExParam ¶ added in v0.7.0
type ExParam struct {
Fileparam *ExFileparam
Filter *FilterParam
// contains filtered or unexported fields
}
type ExParamConst ¶ added in v0.7.0
type ExParamConst struct {
ParallelLoad bool
LoadEmptyNumericAsZero bool
StrictSqlMode bool
Close byte
Idx int
ColumnListLen int32 // load ... (col1, col2 , col3), ColumnListLen is 3
CreateSql string
// letter case: origin
Attrs []plan.ExternAttr
Cols []*plan.ColDef
FileList []string
FileSize []int64
FileOffset []int64
FileOffsetTotal []*pipeline.FileOffset
// Optional Parquet row group shards. Empty means whole-file scan.
ParquetRowGroupShards []*pipeline.ParquetRowGroupShard
Ctx context.Context
Extern *tree.ExternParam
ClusterTable *plan.ClusterTable
// contains filtered or unexported fields
}
type External ¶
type External struct {
Es *ExternalParam
vm.OperatorBase
colexec.Projection
// contains filtered or unexported fields
}
func NewArgument ¶ added in v1.2.0
func NewArgument() *External
func (*External) ExecProjection ¶
func (*External) GetOperatorBase ¶
func (external *External) GetOperatorBase() *vm.OperatorBase
func (*External) WithEs ¶
func (external *External) WithEs(es *ExternalParam) *External
type ExternalFileReader ¶
type ExternalFileReader interface {
// Open opens a file and initializes internal state.
// fileEmpty=true means the file is empty (e.g. 0-row Parquet),
// Call should Close then finishCurrentFile and continue to next file.
Open(param *ExternalParam, proc *process.Process) (fileEmpty bool, err error)
// ReadBatch reads one batch of data into buf.
// Returns true when the current file is fully read.
ReadBatch(ctx context.Context, buf *batch.Batch, proc *process.Process, analyzer process.Analyzer) (fileFinished bool, err error)
// Close closes the current file and releases resources.
Close() error
}
ExternalFileReader is the unified interface for reading external files. Each format (CSV/Parquet/ZoneMap) implements this interface independently.
Lifecycle: NewXxxReader() → Open() → ReadBatch()* → Close() → Open() → ... Reader saves param reference in Open, subsequent methods access it via r.param.
type ExternalParam ¶
type ExternalParam struct {
// Externally passed parameters that will not change
ExParamConst
// Inner parameters
ExParam
}
Use for External table scan param
type FilterParam ¶ added in v0.7.0
type HivePartSegment ¶
HivePartSegment is the parsed result of a single Hive partition directory segment.
func ParseHivePartitionSegment ¶
func ParseHivePartitionSegment(segment string) (seg HivePartSegment, isHive bool, err error)
ParseHivePartitionSegment parses a directory segment like "year=2024" into key/value. Keys stay in the raw path domain and are not URL-decoded. Values are decoded exactly once for SQL-visible partition values; callers must continue to use raw paths when listing or opening files.
Returns:
- (seg, true, nil): valid key=value segment (value may be empty string)
- (_, false, nil): not a key=value format (caller treats as non-partition dir)
type HivePartitionListCacheEntry ¶
type HivePartitionListCacheEntry struct {
Entries []fileservice.DirEntry
ExpireAt time.Time
SizeHint int64
// contains filtered or unexported fields
}
type ListDirFunc ¶
ListDirFunc abstracts directory listing for testability and S3/local duality.
func NewListDirFunc ¶
func NewListDirFunc(param *tree.ExternParam) ListDirFunc
NewListDirFunc creates a ListDirFunc backed by GetForETLWithType.
type MatchResult ¶
type MatchResult int
MatchResult is a three-state result for partition value comparison.
const ( MatchTrue MatchResult = iota // definitely matches MatchFalse // definitely does not match (safe to prune) MatchUnknown // cannot determine (must keep directory) )
type ParquetHandler ¶ added in v1.2.0
type ParquetHandler struct {
// contains filtered or unexported fields
}
type ParquetReader ¶
type ParquetReader struct {
// contains filtered or unexported fields
}
ParquetReader handles Parquet format files.
func NewParquetReader ¶
func NewParquetReader(param *ExternalParam, proc *process.Process) *ParquetReader
func (*ParquetReader) Close ¶
func (r *ParquetReader) Close() error
func (*ParquetReader) Open ¶
func (r *ParquetReader) Open(param *ExternalParam, proc *process.Process) (fileEmpty bool, err error)
type ParseLineHandler ¶
type ParseLineHandler struct {
// contains filtered or unexported fields
}
type PartitionAnd ¶
type PartitionAnd struct {
Children []PartitionPruneExpr
}
func (*PartitionAnd) EvalPartial ¶
func (a *PartitionAnd) EvalPartial(values map[string]string, colTypes map[string]tree.HivePartColType) MatchResult
func (*PartitionAnd) ReferencedCols ¶
func (a *PartitionAnd) ReferencedCols() map[string]bool
type PartitionAtom ¶
type PartitionAtom struct {
ColName string
Op PartitionOp
Values []string
}
func (*PartitionAtom) EvalPartial ¶
func (a *PartitionAtom) EvalPartial(values map[string]string, colTypes map[string]tree.HivePartColType) MatchResult
func (*PartitionAtom) ReferencedCols ¶
func (a *PartitionAtom) ReferencedCols() map[string]bool
type PartitionDiscoveryResult ¶
type PartitionDiscoveryResult struct {
Files []PartitionFileEntry
PartitionCount int
PrunedCount int
ListCalls int
CacheHits int
CacheMisses int
ListConcurrency int
DiscoveryDuration time.Duration
InferredPartitionCols []string
DiscoveredFiles int
DiscoveredBytes int64
PrunedFiles int
PrunedBytes int64
DirectPrefixHits int
DirectPrefixMisses int
// contains filtered or unexported fields
}
PartitionDiscoveryResult holds the outcome of Hive partition discovery.
func DiscoverHivePartitions ¶
func DiscoverHivePartitions( ctx context.Context, listDir ListDirFunc, basePath string, partCols []string, colTypes []tree.HivePartColType, predicates []PartitionPredicate, ) (*PartitionDiscoveryResult, error)
DiscoverHivePartitions performs recursive list-and-filter partition discovery.
func DiscoverHivePartitionsWithPruneExpr ¶
func DiscoverHivePartitionsWithPruneExpr( ctx context.Context, listDir ListDirFunc, basePath string, partCols []string, colTypes []tree.HivePartColType, pruneExpr PartitionPruneExpr, opts *DiscoverOptions, ) (*PartitionDiscoveryResult, error)
type PartitionFileEntry ¶
PartitionFileEntry represents a discovered file within a Hive partition structure.
type PartitionOp ¶
type PartitionOp int
const ( PartOpEq PartitionOp = iota PartOpIn PartOpLt PartOpLe PartOpGt PartOpGe PartOpBetween PartOpIsNull PartOpIsNotNull )
type PartitionOr ¶
type PartitionOr struct {
Children []PartitionPruneExpr
}
func (*PartitionOr) EvalPartial ¶
func (o *PartitionOr) EvalPartial(values map[string]string, colTypes map[string]tree.HivePartColType) MatchResult
func (*PartitionOr) ReferencedCols ¶
func (o *PartitionOr) ReferencedCols() map[string]bool
type PartitionPredicate ¶
type PartitionPredicate struct {
ColName string
Op PartitionOp
Values []string
}
PartitionPredicate represents a filter hint for partition pruning.
func ExtractPartitionPredicatesFromExprs ¶
func ExtractPartitionPredicatesFromExprs( tableDef *plan.TableDef, partFilters []*plan.Expr, partColSet map[string]bool, ) []PartitionPredicate
ExtractPartitionPredicatesFromExprs converts partition filter expressions into PartitionPredicate hints for directory-level pruning. Supports col = const (PartOpEq) and col IN (const, ...) (PartOpIn). Expressions that cannot be structurally decomposed are silently skipped.
Note: After optimizer constant-folding (rule.ConstantFold applies to all nodes), IN lists may be folded from Expr_List to Expr_Vec. Both forms are handled.
type PartitionPruneExpr ¶
type PartitionPruneExpr interface {
EvalPartial(values map[string]string, colTypes map[string]tree.HivePartColType) MatchResult
ReferencedCols() map[string]bool
}
PartitionPruneExpr is a conservative, directory-level predicate tree. EvalPartial is allowed to return MatchUnknown whenever the currently-known partition values are insufficient or SQL semantics cannot be reproduced exactly from path strings. Only MatchFalse may prune a directory.
type ZonemapFileparam ¶ added in v0.7.0
type ZonemapFileparam struct {
// contains filtered or unexported fields
}
type ZonemapReader ¶
type ZonemapReader struct {
// contains filtered or unexported fields
}
ZonemapReader handles MO internal result files (RESULT_SCAN).
func NewZonemapReader ¶
func NewZonemapReader(param *ExternalParam, proc *process.Process) *ZonemapReader
NewZonemapReader creates a ZonemapReader. zonemappable is computed here since only ZonemapReader uses it.
func (*ZonemapReader) Close ¶
func (r *ZonemapReader) Close() error
func (*ZonemapReader) Open ¶
func (r *ZonemapReader) Open(param *ExternalParam, proc *process.Process) (fileEmpty bool, err error)