This repository has been archived by the owner on Jan 28, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 109
/
Copy pathrules.go
68 lines (62 loc) · 2.64 KB
/
rules.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package analyzer
import (
errors "gopkg.in/src-d/go-errors.v1"
)
// DefaultRules to apply when analyzing nodes.
var DefaultRules = []Rule{
{"resolve_natural_joins", resolveNaturalJoins},
{"resolve_orderby_literals", resolveOrderByLiterals},
{"resolve_orderby", resolveOrderBy},
{"resolve_grouping_columns", resolveGroupingColumns},
{"qualify_columns", qualifyColumns},
{"resolve_columns", resolveColumns},
{"resolve_database", resolveDatabase},
{"resolve_star", resolveStar},
{"resolve_functions", resolveFunctions},
{"reorder_aggregations", reorderAggregations},
{"reorder_projection", reorderProjection},
{"move_join_conds_to_filter", moveJoinConditionsToFilter},
{"eval_filter", evalFilter},
{"optimize_distinct", optimizeDistinct},
}
// OnceBeforeDefault contains the rules to be applied just once before the
// DefaultRules.
var OnceBeforeDefault = []Rule{
{"resolve_subqueries", resolveSubqueries},
{"resolve_tables", resolveTables},
}
// OnceAfterDefault contains the rules to be applied just once after the
// DefaultRules.
var OnceAfterDefault = []Rule{
{"remove_unnecessary_converts", removeUnnecessaryConverts},
{"assign_catalog", assignCatalog},
{"prune_columns", pruneColumns},
{"pushdown", pushdown},
{"erase_projection", eraseProjection},
}
// OnceAfterAll contains the rules to be applied just once after all other
// rules have been applied.
var OnceAfterAll = []Rule{
{"track_process", trackProcess},
{"parallelize", parallelize},
{"clear_warnings", clearWarnings},
}
var (
// ErrColumnTableNotFound is returned when the column does not exist in a
// the table.
ErrColumnTableNotFound = errors.NewKind("table %q does not have column %q")
// ErrColumnNotFound is returned when the column does not exist in any
// table in scope.
ErrColumnNotFound = errors.NewKind("column %q could not be found in any table in scope")
// ErrAmbiguousColumnName is returned when there is a column reference that
// is present in more than one table.
ErrAmbiguousColumnName = errors.NewKind("ambiguous column name %q, it's present in all these tables: %v")
// ErrFieldMissing is returned when the field is not on the schema.
ErrFieldMissing = errors.NewKind("field %q is not on schema")
// ErrOrderByColumnIndex is returned when in an order clause there is a
// column that is unknown.
ErrOrderByColumnIndex = errors.NewKind("unknown column %d in order by clause")
// ErrMisusedAlias is returned when a alias is defined and used in the same projection.
ErrMisusedAlias = errors.NewKind("column %q does not exist in scope, but there is an alias defined in" +
" this projection with that name. Aliases cannot be used in the same projection they're defined in")
)