Support MySQL Protocol (TCP only) (#22639)

Signed-off-by: longjiquan <jiquan.long@zilliz.com>
pull/23395/head
Jiquan Long 2023-03-13 14:19:53 +08:00 committed by longjiquan
parent 2c038612ec
commit dbfc812387
98 changed files with 40648 additions and 464 deletions

View File

@ -7,6 +7,14 @@ run:
- docs
- scripts
- internal/core
- internal/mysqld/parser/antlrparser/parser
- internal/planparserv2/generated
skip-files:
# The worst lint rule of golang.
- internal/mysqld/parser/antlrparser/ast_builder.go
- internal/mysqld/parser/antlrparser/node_ret.go
- internal/mysqld/planner/sql_statement.go
- internal/mysqld/planner/sql_statements.go
linters:
disable-all: true

View File

@ -522,3 +522,7 @@ trace:
sampleFraction: 0
jaeger:
url: # when exporter is jaeger should set the jaeger's URL
mysqld:
tcpPort: 3306
# TODO: support socket.

46
go.mod
View File

@ -3,22 +3,28 @@ module github.com/milvus-io/milvus
go 1.18
require (
github.com/99designs/keyring v1.2.1 // indirect
github.com/BurntSushi/toml v1.0.0 // indirect
github.com/DATA-DOG/go-sqlmock v1.5.0
github.com/aliyun/credentials-go v1.2.6
github.com/antlr/antlr4/runtime/Go/antlr v0.0.0-20210826220005-b48c857c3a0e
github.com/antonmedv/expr v1.8.9
github.com/apache/arrow/go/v8 v8.0.0-20220322092137-778b1772fd20
github.com/apache/pulsar-client-go v0.6.1-0.20210728062540-29414db801a7
github.com/apache/thrift v0.15.0 // indirect
github.com/benesch/cgosymbolizer v0.0.0-20190515212042-bec6fe6e597b
github.com/bits-and-blooms/bloom/v3 v3.0.1
github.com/blang/semver/v4 v4.0.0
github.com/casbin/casbin/v2 v2.44.2
github.com/casbin/json-adapter/v2 v2.0.0
github.com/cockroachdb/errors v1.9.1
github.com/confluentinc/confluent-kafka-go v1.9.1
github.com/containerd/cgroups v1.0.4
github.com/gin-gonic/gin v1.7.7
github.com/gofrs/flock v0.8.1
github.com/golang/protobuf v1.5.3
github.com/klauspost/compress v1.14.4
github.com/lingdor/stackerror v0.0.0-20191119040541-976d8885ed76
github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d
github.com/milvus-io/milvus-proto/go-api v0.0.0-20230411174625-2c86533465fb
github.com/milvus-io/milvus/pkg v0.0.0-00010101000000-000000000000
@ -28,8 +34,13 @@ require (
github.com/quasilyte/go-ruleguard/dsl v0.3.21
github.com/samber/lo v1.27.0
github.com/sbinet/npyio v0.6.0
github.com/shirou/gopsutil/v3 v3.22.9
github.com/spaolacci/murmur3 v1.1.0
github.com/spf13/cast v1.3.1
github.com/spf13/viper v1.8.1
github.com/streamnative/pulsarctl v0.5.0
github.com/stretchr/testify v1.8.1
github.com/tecbot/gorocksdb v0.0.0-20191217155057-f0fad39f321c
go.etcd.io/etcd/api/v3 v3.5.5
go.etcd.io/etcd/client/v3 v3.5.5
go.etcd.io/etcd/server/v3 v3.5.5
@ -76,6 +87,7 @@ require (
github.com/ardielle/ardielle-go v1.5.2 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/bits-and-blooms/bitset v1.2.0 // indirect
github.com/blang/semver/v4 v4.0.0
github.com/campoy/embedmd v1.0.0 // indirect
github.com/cenkalti/backoff/v4 v4.2.0 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
@ -203,6 +215,39 @@ require (
sigs.k8s.io/yaml v1.2.0 // indirect
)
require github.com/ianlancetaylor/cgosymbolizer v0.0.0-20221217025313-27d3c9f66b6a // indirect
require (
github.com/aliyun/credentials-go v1.2.6
github.com/cockroachdb/errors v1.9.1
github.com/uber/jaeger-client-go v2.30.0+incompatible
go.opentelemetry.io/otel/exporters/jaeger v1.11.2
go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.11.2
)
require (
github.com/alibabacloud-go/debug v0.0.0-20190504072949-9472017b5c68 // indirect
github.com/alibabacloud-go/tea v1.1.8 // indirect
github.com/cenkalti/backoff/v4 v4.2.0 // indirect
github.com/cockroachdb/logtags v0.0.0-20211118104740-dabe8e521a4f // indirect
github.com/cockroachdb/redact v1.1.3 // indirect
github.com/form3tech-oss/jwt-go v3.2.3+incompatible // indirect
github.com/getsentry/sentry-go v0.12.0 // indirect
github.com/go-logr/logr v1.2.3 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/golang-jwt/jwt v3.2.2+incompatible // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.7.0 // indirect
github.com/kr/pretty v0.3.0 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/olekukonko/tablewriter v0.0.5 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/rogpeppe/go-internal v1.8.1 // indirect
go.opentelemetry.io/otel/exporters/otlp/internal/retry v1.11.2 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.11.2 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.11.2 // indirect
go.opentelemetry.io/otel/metric v0.34.0 // indirect
)
replace (
github.com/apache/pulsar-client-go => github.com/milvus-io/pulsar-client-go v0.6.10
github.com/bketelsen/crypt => github.com/bketelsen/crypt v0.0.4 // Fix security alert for core-os/etcd
@ -210,6 +255,7 @@ replace (
github.com/milvus-io/milvus/pkg => ./pkg
github.com/streamnative/pulsarctl => github.com/xiaofan-luan/pulsarctl v0.5.1
github.com/tecbot/gorocksdb => github.com/milvus-io/gorocksdb v0.0.0-20220624081344-8c5f4212846b // indirect
github.com/xelabs/go-mysqlstack => github.com/longjiquan/go-mysqlstack v0.0.0-20210512092920-666657c8bdb5
)
exclude github.com/apache/pulsar-client-go/oauth2 v0.0.0-20211108044248-fe3b7c4e445b

21
go.sum
View File

@ -17,6 +17,7 @@ cloud.google.com/go v0.72.0/go.mod h1:M+5Vjvlc2wnp6tjzE102Dw08nGShTscUx2nZMufOKP
cloud.google.com/go v0.74.0/go.mod h1:VV1xSbzvo+9QJOxLDaJfTjx5e+MePCpCWwvftOeQmWk=
cloud.google.com/go v0.78.0/go.mod h1:QjdrLG0uq+YwhjoVOLsS1t7TW8fs36kLs4XO5R5ECHg=
cloud.google.com/go v0.79.0/go.mod h1:3bzgcEeQlzbuEAYu4mrWhKqWjmpprinYgKJLgKHnbb8=
cloud.google.com/go v0.81.0 h1:at8Tk2zUz63cLPR0JPWm5vp77pEZmzxEQBEfRKn1VV8=
cloud.google.com/go v0.81.0/go.mod h1:mk/AM35KwGk/Nm2YSeZbxXdrNK3KZOYHmLkOqC2V6E0=
cloud.google.com/go/bigquery v1.0.1/go.mod h1:i/xbL2UlR5RvWAURpBYZTtm/cXjCha9lbfbpx4poX+o=
cloud.google.com/go/bigquery v1.3.0/go.mod h1:PjpwJnslEMmckchkHFfq+HTD2DmtT67aNFKH1/VBDHE=
@ -134,6 +135,7 @@ github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA
github.com/certifi/gocertifi v0.0.0-20191021191039-0944d244cd40/go.mod h1:sGbDF6GwGcLpkNXPUTkMRoywsNa/ol15pxFe6ERfguA=
github.com/certifi/gocertifi v0.0.0-20200922220541-2c3bb06c6054/go.mod h1:sGbDF6GwGcLpkNXPUTkMRoywsNa/ol15pxFe6ERfguA=
github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc=
github.com/cespare/xxhash/v2 v2.1.1 h1:6MnRN8NT7+YBpUIWxHtefFZOKTAPgGjpQSxqLNn0+qY=
github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44=
github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
@ -342,6 +344,7 @@ github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw
github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
github.com/golang/protobuf v1.5.1/go.mod h1:DopwsBzvsk0Fs44TXzsVbJyPhcCPeIwnvohx4u74HPM=
github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw=
github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg=
github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
@ -477,6 +480,7 @@ github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX
github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
github.com/json-iterator/go v1.1.11 h1:uVUAXhF2To8cbw/3xN3pxj6kk7TYKs98NIrTqPlMWAQ=
github.com/json-iterator/go v1.1.11/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
@ -532,6 +536,7 @@ github.com/labstack/gommon v0.3.0/go.mod h1:MULnywXg0yavhxWKc+lOruYdAhDwPK9wf0OL
github.com/leodido/go-urn v1.2.0 h1:hpXL4XnriNwQ/ABnpepYM/1vCLWNDfUNts8dX3xTG6Y=
github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII=
github.com/lingdor/stackerror v0.0.0-20191119040541-976d8885ed76 h1:IVlcvV0CjvfBYYod5ePe89l+3LBAl//6n9kJ9Vr2i0k=
github.com/lingdor/stackerror v0.0.0-20191119040541-976d8885ed76/go.mod h1:Iu9BHUvTh8/KpbuSoKx/CaJEdJvFxSverxIy7I+nq7s=
github.com/linkedin/goavro v2.1.0+incompatible/go.mod h1:bBCwI2eGYpUI/4820s67MElg9tdeLbINjLjiM2xZFYM=
github.com/linkedin/goavro/v2 v2.9.8/go.mod h1:UgQUb2N/pmueQYH9bfqFioWxzYCZXSfF8Jw03O5sjqA=
github.com/linkedin/goavro/v2 v2.10.0/go.mod h1:UgQUb2N/pmueQYH9bfqFioWxzYCZXSfF8Jw03O5sjqA=
@ -561,7 +566,10 @@ github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27k
github.com/mattn/go-runewidth v0.0.4/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU=
github.com/mattn/go-runewidth v0.0.8 h1:3tS41NlGYSmhhe/8fhGRzc+z3AYCw1Fe1WAyLuujKs0=
github.com/mattn/go-runewidth v0.0.8/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
github.com/mattn/go-runewidth v0.0.9 h1:Lm995f3rfxdpd6TSmuVCHVb/QhupuXlYr8sCI/QdE+0=
github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
github.com/mattn/goveralls v0.0.2/go.mod h1:8d1ZMHsd7fW6IRPKQh46F2WRpyib5/X4FOpevwGNQEw=
github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU=
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
github.com/matttproud/golang_protobuf_extensions v1.0.4 h1:mmDVorXM7PCGKw94cs5zkfA9PSy5pEvNWRP0ET0TIVo=
github.com/matttproud/golang_protobuf_extensions v1.0.4/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4=
@ -603,6 +611,7 @@ github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJ
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
github.com/modern-go/reflect2 v1.0.1 h1:9f412s+6RmYXLWZSEzVVgPGK7C2PphHj5RJrvfx9AWI=
github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
@ -615,6 +624,7 @@ github.com/nats-io/jwt v0.3.0/go.mod h1:fRYCDE99xlTsqUzISS1Bi75UBJ6ljOJQOAAu5Vgl
github.com/nats-io/nats.go v1.9.1/go.mod h1:ZjDU1L/7fJ09jvUSRVBR2e7+RnLiiIQyqyzEE/Zbp4w=
github.com/nats-io/nkeys v0.1.0/go.mod h1:xpnFELMwJABBLVhffcfd1MZx6VsNRFpEugbxziKVo7w=
github.com/nats-io/nuid v1.0.1/go.mod h1:19wcPz3Ph3q0Jbyiqsd0kePYG7A95tJPxeL+1OSON2c=
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs=
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
github.com/nrwiersma/avro-benchmarks v0.0.0-20210913175520-21aec48c8f76/go.mod h1:iKyFMidsk/sVYONJRE372sJuX/QTRPacU7imPqqsu7g=
github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A=
@ -622,6 +632,7 @@ github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE=
github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU=
github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U=
github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec=
github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY=
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/ginkgo v1.10.3/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk=
@ -669,12 +680,14 @@ github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXP
github.com/prometheus/client_golang v0.9.3/go.mod h1:/TN21ttK/J9q6uSwhBd54HahCDft0ttaMvbicHlPoso=
github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo=
github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M=
github.com/prometheus/client_golang v1.11.1 h1:+4eQaD7vAZ6DsfsxB15hbE0odUjGI5ARs9yskGu1v4s=
github.com/prometheus/client_golang v1.11.1/go.mod h1:Z6t4BnS23TR94PD6BsDNk8yVqroYurpAkEiz0P2BEV0=
github.com/prometheus/client_golang v1.14.0 h1:nJdhIvne2eSX/XRAFV9PcvFFRbrjbcTUj0VP62TMhnw=
github.com/prometheus/client_golang v1.14.0/go.mod h1:8vpkKitgIVNcqrRBWh1C4TIUQgYNtG/XQE4E/Zae36Y=
github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
github.com/prometheus/client_model v0.2.0 h1:uq5h0d+GuxiXLJLNABMgp2qUWDPiLvgCzz2dUR+/W/M=
github.com/prometheus/client_model v0.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
github.com/prometheus/client_model v0.3.0 h1:UBgGFHqYdG/TPFD1B1ogZywDqEkwp3fBMvqdiQ7Xew4=
github.com/prometheus/client_model v0.3.0/go.mod h1:LDGWKZIo7rky3hgvBe+caln+Dr3dPggB5dvjtD7w9+w=
@ -682,6 +695,7 @@ github.com/prometheus/common v0.0.0-20181113130724-41aa239b4cce/go.mod h1:daVV7q
github.com/prometheus/common v0.4.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4=
github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4=
github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo=
github.com/prometheus/common v0.26.0 h1:iMAkS2TDoNWnKM+Kopnx/8tnEStIfpYA0ur0xQzzhMQ=
github.com/prometheus/common v0.26.0/go.mod h1:M7rCNAaPfAosfx8veZJCuw84e35h3Cfd9VFqTh1DIvc=
github.com/prometheus/common v0.42.0 h1:EKsfXEYo4JpWMHH5cg+KOUWeuJSov1Id8zGR8eeI1YM=
github.com/prometheus/common v0.42.0/go.mod h1:xBwqVerjNdUDjgODMpudtOMwlOwf2SaTr1yjz4b7Zbc=
@ -689,6 +703,7 @@ github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R
github.com/prometheus/procfs v0.0.0-20190507164030-5867b95ac084/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA=
github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA=
github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU=
github.com/prometheus/procfs v0.6.0 h1:mxy4L2jP6qMonqmq+aTtOx1ifVWUgG/TAmntgbh3xv4=
github.com/prometheus/procfs v0.6.0/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA=
github.com/prometheus/procfs v0.9.0 h1:wzCHvIvM5SxWqYvwgVL7yJY8Lz3PKn49KQtpgMYJfhI=
github.com/prometheus/procfs v0.9.0/go.mod h1:+pB4zwohETzFnmlpe6yd2lSc+0/46IYZRB/chUwxUZY=
@ -715,6 +730,8 @@ github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb
github.com/ryanuber/columnize v2.1.0+incompatible/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts=
github.com/samber/lo v1.27.0 h1:GOyDWxsblvqYobqsmUuMddPa2/mMzkKyojlXol4+LaQ=
github.com/samber/lo v1.27.0/go.mod h1:it33p9UtPMS7z72fP4gw/EIfQB2eI8ke7GR2wc6+Rhg=
github.com/sandertv/go-formula/v2 v2.0.0-alpha.7 h1:j6ZnqcpnlGG9oBdhfiGgQ4aQAHEKsMlePvOfD+y5O6s=
github.com/sandertv/go-formula/v2 v2.0.0-alpha.7/go.mod h1:Ag4V2fiOHWXct3SraXNN3dFzFtyu9vqBfrjfYWMGLhE=
github.com/sanity-io/litter v1.2.0/go.mod h1:JF6pZUFgu2Q0sBZ+HSV35P8TVPI1TTzEwyu9FXAw2W4=
github.com/santhosh-tekuri/jsonschema/v5 v5.0.0/go.mod h1:FKdcjfQW6rpZSnxxUvEA5H/cDPdvJ/SZJQLWWXWGrZ0=
github.com/sbinet/npyio v0.6.0 h1:IyqqQIzRjDym9xnIXsToCKei/qCzxDP+Y74KoMlMgXo=
@ -890,6 +907,7 @@ go.opentelemetry.io/proto/otlp v0.19.0 h1:IVN6GR+mhC4s5yfcTbmzHYODqvWAp3ZedA2SJP
go.opentelemetry.io/proto/otlp v0.19.0/go.mod h1:H7XAot3MsfNsj7EXtrA2q5xSNQ10UqI405h3+duxN4U=
go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
go.uber.org/atomic v1.6.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ=
go.uber.org/atomic v1.7.0 h1:ADUqmZGgLDDfbSL9ZmPxKTybcoEYHgpYfELNoN+7hsw=
go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
go.uber.org/atomic v1.10.0 h1:9qC72Qh0+3MqyJbAn8YU5xVq1frD8bn3JtD2oXtafVQ=
go.uber.org/atomic v1.10.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0=
@ -1232,6 +1250,7 @@ golang.org/x/tools v0.7.0/go.mod h1:4pg6aUX35JBAogB10C9AtvVL+qowtN4pT3CGSQex14s=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 h1:H2TDz8ibqkAF6YGhCdN3jS9O0/s90v0rJh3X/OLHEUk=
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2/go.mod h1:K8+ghG5WaK9qNqU5K3HdILfMLy1f3aNYFI/wnl100a8=
@ -1320,6 +1339,7 @@ google.golang.org/genproto v0.0.0-20210602131652-f16073e35f0c/go.mod h1:UODoCrxH
google.golang.org/genproto v0.0.0-20210624195500-8bfb893ecb84/go.mod h1:SzzZ/N+nwJDaO1kznhnlzqS8ocJICar6hYhVyhi++24=
google.golang.org/genproto v0.0.0-20211118181313-81c1377c94b1/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc=
google.golang.org/genproto v0.0.0-20220126215142-9970aeb2e350/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc=
google.golang.org/genproto v0.0.0-20220503193339-ba3ae3f07e29 h1:DJUvgAPiJWeMBiT+RzBVcJGQN7bAEWS5UEoMshES9xs=
google.golang.org/genproto v0.0.0-20220503193339-ba3ae3f07e29/go.mod h1:RAyBrSAP7Fh3Nc84ghnVLDPuV51xc9agzmm4Ph6i0Q4=
google.golang.org/genproto v0.0.0-20230331144136-dcfb400f0633 h1:0BOZf6qNozI3pkN3fJLwNubheHJYHhMh91GRFOWWK08=
google.golang.org/genproto v0.0.0-20230331144136-dcfb400f0633/go.mod h1:UUQDJDOlWu4KYeJZffbWgBkS1YFobzKbLVfK69pe0Ak=
@ -1376,6 +1396,7 @@ gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20200902074654-038fdea0a05b h1:QRR6H1YWRnHb4Y/HeNFCTJLFVxaq6wH4YuVdsUOr75U=
gopkg.in/check.v1 v1.0.0-20200902074654-038fdea0a05b/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
gopkg.in/errgo.v1 v1.0.0/go.mod h1:CxwszS/Xz1C49Ucd2i6Zil5UToP1EmyrFhKaMVbg1mk=

View File

@ -30,6 +30,10 @@ import (
"sync"
"time"
"go.uber.org/zap/zapcore"
"github.com/milvus-io/milvus/internal/mysqld"
"github.com/milvus-io/milvus/internal/proxy/accesslog"
"github.com/milvus-io/milvus/internal/util/componentutil"
"github.com/milvus-io/milvus/internal/util/dependency"
@ -87,6 +91,8 @@ type Server struct {
rootCoordClient types.RootCoord
dataCoordClient types.DataCoord
queryCoordClient types.QueryCoord
mysqlServer *mysqld.Server
}
// NewServer create a Proxy server.
@ -280,6 +286,37 @@ func (s *Server) startInternalGrpc(grpcPort int, errChan chan error) {
}
}
func getLogLevel() zapcore.Level {
level := zapcore.InfoLevel
cfg := paramtable.Get().LogCfg
_ = level.UnmarshalText([]byte(cfg.Level.GetValue()))
return level
}
func getMysqlTCPPort() int {
cfg := paramtable.Get().MysqldConfig
return cfg.TCPPort.GetAsInt()
}
func (s *Server) startMySQLServer() error {
port := getMysqlTCPPort()
level := getLogLevel()
mysqlServer, err := mysqld.NewServer(s.proxy, port, level)
if err != nil {
return err
}
s.mysqlServer = mysqlServer
if err := s.mysqlServer.Start(); err != nil {
return err
}
log.Info("start mysql server", zap.Int("tcpPort", port), zap.String("level", level.String()))
return nil
}
// Start start the Proxy Server
func (s *Server) Run() error {
log.Debug("init Proxy server")
@ -469,6 +506,11 @@ func (s *Server) start() error {
return err
}
if err := s.startMySQLServer(); err != nil {
log.Warn("failed to start mysql server", zap.Error(err))
return err
}
return nil
}
@ -505,6 +547,10 @@ func (s *Server) Stop() error {
return err
}
if s.mysqlServer != nil {
return s.mysqlServer.Close()
}
return nil
}

3992
internal/mocks/mock_proxy.go Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,17 @@
package executor
import "github.com/milvus-io/milvus/internal/mysqld/planner"
type Compiler interface {
Compile(plan *planner.LogicalPlan) (*planner.PhysicalPlan, error)
}
type defaultCompiler struct{}
func (c defaultCompiler) Compile(plan *planner.LogicalPlan) (*planner.PhysicalPlan, error) {
return &planner.PhysicalPlan{Node: plan.Node}, nil
}
func NewDefaultCompiler() Compiler {
return &defaultCompiler{}
}

View File

@ -0,0 +1,19 @@
package executor
import (
"testing"
"github.com/milvus-io/milvus/internal/mysqld/planner"
"github.com/stretchr/testify/assert"
)
func Test_defaultCompiler_Compile(t *testing.T) {
plan := &planner.LogicalPlan{
Node: planner.NewNodeConstant("20230306", planner.WithStringLiteral("20230306")),
}
c := NewDefaultCompiler()
physicalPlan, err := c.Compile(plan)
assert.NoError(t, err)
constant := physicalPlan.Node.(*planner.NodeConstant)
assert.Equal(t, "20230306", constant.StringLiteral.Unwrap())
}

View File

@ -0,0 +1,354 @@
package executor
import (
"context"
"fmt"
"strconv"
"github.com/cockroachdb/errors"
"github.com/milvus-io/milvus/internal/mysqld/parser/antlrparser"
"github.com/milvus-io/milvus/internal/util/typeutil"
"github.com/milvus-io/milvus-proto/go-api/schemapb"
"github.com/milvus-io/milvus-proto/go-api/commonpb"
"github.com/milvus-io/milvus-proto/go-api/milvuspb"
"github.com/milvus-io/milvus/internal/util/commonpbutil"
querypb "github.com/xelabs/go-mysqlstack/sqlparser/depends/query"
"github.com/milvus-io/milvus/internal/mysqld/planner"
"github.com/milvus-io/milvus/internal/types"
"github.com/xelabs/go-mysqlstack/sqlparser/depends/sqltypes"
)
type Executor interface {
Run(ctx context.Context, plan *planner.PhysicalPlan) (*sqltypes.Result, error)
}
// defaultExecutor only translates sql to rpc. TODO: Better to use vacalno model or batch model.
type defaultExecutor struct {
s types.ProxyComponent
}
func (e *defaultExecutor) Run(ctx context.Context, plan *planner.PhysicalPlan) (*sqltypes.Result, error) {
statements := antlrparser.GetSqlStatements(plan.Node)
if statements == nil {
return nil, fmt.Errorf("invalid node, sql should be parsed to statements")
}
l := len(statements.Statements)
if l != 1 {
return nil, fmt.Errorf("only one statement is supported")
}
return e.dispatch(ctx, statements.Statements[0])
}
func (e *defaultExecutor) dispatch(ctx context.Context, n *planner.NodeSqlStatement) (*sqltypes.Result, error) {
if n.DmlStatement.IsSome() {
return e.dispatchDmlStatement(ctx, n.DmlStatement.Unwrap())
}
return nil, fmt.Errorf("invalid sql statement, only dml statement is supported")
}
func (e *defaultExecutor) dispatchDmlStatement(ctx context.Context, n *planner.NodeDmlStatement) (*sqltypes.Result, error) {
if n.SelectStatement.IsSome() {
return e.execSelect(ctx, n.SelectStatement.Unwrap())
}
return nil, fmt.Errorf("invalid dml statement, only select statement is supported")
}
func (e *defaultExecutor) execSelect(ctx context.Context, n *planner.NodeSelectStatement) (*sqltypes.Result, error) {
if !n.SimpleSelect.IsSome() {
return nil, fmt.Errorf("invalid select statement, only simple select is supported")
}
stmt := n.SimpleSelect.Unwrap()
if stmt.LockClause.IsSome() {
return nil, fmt.Errorf("invalid simple select statement, lock clause is not supported")
}
if !stmt.Query.IsSome() {
return nil, fmt.Errorf("invalid simple select statement, only query is supported")
}
q := stmt.Query.Unwrap()
if q.Limit.IsSome() {
// TODO: use pagination.
return nil, fmt.Errorf("invalid query statement, limit/offset is not supported")
}
if len(q.SelectSpecs) != 0 {
return nil, fmt.Errorf("invalid query statement, select spec is not supported")
}
if !q.From.IsSome() {
return nil, fmt.Errorf("invalid query statement, table source is not specified")
}
from := q.From.Unwrap()
if len(from.TableSources) != 1 {
return nil, fmt.Errorf("invalid query statement, only one table source is supported")
}
tableName := from.TableSources[0].TableName.Unwrap()
outputFields, match, err := getOutputFieldsOrMatchCountRule(q.SelectElements)
if err != nil {
return nil, err
}
if match && !from.Where.IsSome() { // count without filter.
rowCnt, err := e.execCountWithoutFilter(ctx, tableName)
if err != nil {
return nil, err
}
result1 := wrapCountResult(rowCnt, "count(*)")
return result1, nil
}
if match && from.Where.IsSome() { // count with filter.
filter := planner.NewExprTextRestorer().RestoreExprText(from.Where.Unwrap())
return e.execCountWithFilter(ctx, tableName, filter)
}
// `match` is false.
if !from.Where.IsSome() { // query without filter.
return nil, fmt.Errorf("query without filter is not supported")
}
filter := planner.NewExprTextRestorer().RestoreExprText(from.Where.Unwrap())
res, err := e.execQuery(ctx, tableName, filter, outputFields)
if err != nil {
return nil, err
}
return wrapQueryResults(res), nil
}
func getOutputFieldsOrMatchCountRule(fields []*planner.NodeSelectElement) (outputFields []string, match bool, err error) {
match = false
l := len(fields)
if l == 1 {
entry := fields[0]
match = entry.FunctionCall.IsSome() &&
entry.FunctionCall.Unwrap().Agg.IsSome() &&
entry.FunctionCall.Unwrap().Agg.Unwrap().AggCount.IsSome()
}
if match {
return nil, match, nil
}
outputFields = make([]string, 0, l)
for _, entry := range fields {
if entry.Star.IsSome() {
// TODO: support `select *`.
return nil, match, fmt.Errorf("* is not supported")
}
if entry.FunctionCall.IsSome() {
return nil, match, fmt.Errorf("combined select elements is not supported")
}
if entry.FullColumnName.IsSome() {
c := entry.FullColumnName.Unwrap()
if c.Alias.IsSome() {
return nil, match, fmt.Errorf("alias for select elements is not supported")
}
outputFields = append(outputFields, c.Name)
}
}
return outputFields, false, nil
}
func (e *defaultExecutor) execCountWithFilter(ctx context.Context, tableName string, filter string) (*sqltypes.Result, error) {
// TODO: check if `*` match vector field.
outputs := []string{"*"}
res, err := e.execQuery(ctx, tableName, filter, outputs)
if err != nil {
return nil, err
}
nColumn := len(res.GetFieldsData())
nRow := 0
if nColumn > 0 {
nRow = typeutil.GetRowCount(res.GetFieldsData()[0])
}
return wrapCountResult(nRow, "count(*)"), nil
}
func (e *defaultExecutor) execCountWithoutFilter(ctx context.Context, tableName string) (int, error) {
req := &milvuspb.GetCollectionStatisticsRequest{
Base: commonpbutil.NewMsgBase(),
CollectionName: tableName,
}
resp, err := e.s.GetCollectionStatistics(ctx, req)
if err != nil {
return 0, err
}
if resp.GetStatus().GetErrorCode() != commonpb.ErrorCode_Success {
return 0, errors.New(resp.GetStatus().GetReason())
}
rowCnt, err := strconv.Atoi(resp.GetStats()[0].GetValue())
if err != nil {
return 0, err
}
return rowCnt, nil
}
func (e *defaultExecutor) execQuery(ctx context.Context, tableName string, filter string, outputs []string) (*milvuspb.QueryResults, error) {
req := &milvuspb.QueryRequest{
Base: commonpbutil.NewMsgBase(),
DbName: "",
CollectionName: tableName,
Expr: filter,
OutputFields: outputs,
PartitionNames: nil,
TravelTimestamp: 0,
GuaranteeTimestamp: 0,
QueryParams: nil,
}
resp, err := e.s.Query(ctx, req)
if err != nil {
return nil, err
}
if resp.GetStatus().GetErrorCode() != commonpb.ErrorCode_Success {
return nil, errors.New(resp.GetStatus().GetReason())
}
return resp, nil
}
func wrapCountResult(rowCnt int, column string) *sqltypes.Result {
result1 := &sqltypes.Result{
Fields: []*querypb.Field{
{
Name: column,
Type: querypb.Type_INT64,
},
},
Rows: [][]sqltypes.Value{
{
sqltypes.NewInt64(int64(rowCnt)),
},
},
}
return result1
}
func wrapQueryResults(res *milvuspb.QueryResults) *sqltypes.Result {
fieldsData := res.GetFieldsData()
nColumn := len(fieldsData)
fields := make([]*querypb.Field, 0, nColumn)
if nColumn <= 0 {
return &sqltypes.Result{}
}
for i := 0; i < nColumn; i++ {
fields = append(fields, getSQLField(res.GetCollectionName(), fieldsData[i]))
}
nRow := typeutil.GetRowCount(fieldsData[0])
rows := make([][]sqltypes.Value, 0, nRow)
for i := 0; i < nRow; i++ {
row := make([]sqltypes.Value, 0, nColumn)
for j := 0; j < nColumn; j++ {
row = append(row, getDataSingle(fieldsData[j], i))
}
rows = append(rows, row)
}
return &sqltypes.Result{
Fields: fields,
Rows: rows,
}
}
func getSQLField(tableName string, fieldData *schemapb.FieldData) *querypb.Field {
return &querypb.Field{
Name: fieldData.GetFieldName(),
Type: toSQLType(fieldData.GetType()),
Table: tableName,
OrgTable: "",
Database: "",
OrgName: "",
ColumnLength: 0,
Charset: 0,
Decimals: 0,
Flags: 0,
}
}
func toSQLType(t schemapb.DataType) querypb.Type {
switch t {
case schemapb.DataType_Bool:
// TODO: tinyint
return querypb.Type_UINT8
case schemapb.DataType_Int8:
return querypb.Type_INT8
case schemapb.DataType_Int16:
return querypb.Type_INT16
case schemapb.DataType_Int32:
return querypb.Type_INT32
case schemapb.DataType_Int64:
return querypb.Type_INT64
case schemapb.DataType_Float:
return querypb.Type_FLOAT32
case schemapb.DataType_Double:
return querypb.Type_FLOAT64
case schemapb.DataType_VarChar:
return querypb.Type_VARCHAR
// TODO: vector.
default:
return querypb.Type_NULL_TYPE
}
}
func getDataSingle(fieldData *schemapb.FieldData, idx int) sqltypes.Value {
switch fieldData.GetType() {
case schemapb.DataType_Bool:
// TODO: tinyint
return sqltypes.NewInt32(1)
case schemapb.DataType_Int8:
v := fieldData.Field.(*schemapb.FieldData_Scalars).Scalars.Data.(*schemapb.ScalarField_IntData).IntData.GetData()[idx]
return sqltypes.MakeTrusted(sqltypes.Int8, strconv.AppendInt(nil, int64(v), 10))
case schemapb.DataType_Int16:
v := fieldData.Field.(*schemapb.FieldData_Scalars).Scalars.Data.(*schemapb.ScalarField_IntData).IntData.GetData()[idx]
return sqltypes.MakeTrusted(sqltypes.Int16, strconv.AppendInt(nil, int64(v), 10))
case schemapb.DataType_Int32:
v := fieldData.Field.(*schemapb.FieldData_Scalars).Scalars.Data.(*schemapb.ScalarField_IntData).IntData.GetData()[idx]
return sqltypes.MakeTrusted(sqltypes.Int32, strconv.AppendInt(nil, int64(v), 10))
case schemapb.DataType_Int64:
v := fieldData.Field.(*schemapb.FieldData_Scalars).Scalars.Data.(*schemapb.ScalarField_LongData).LongData.GetData()[idx]
return sqltypes.MakeTrusted(sqltypes.Int64, strconv.AppendInt(nil, v, 10))
case schemapb.DataType_Float:
v := fieldData.Field.(*schemapb.FieldData_Scalars).Scalars.Data.(*schemapb.ScalarField_FloatData).FloatData.GetData()[idx]
return sqltypes.MakeTrusted(sqltypes.Float32, strconv.AppendFloat(nil, float64(v), 'f', -1, 64))
case schemapb.DataType_Double:
v := fieldData.Field.(*schemapb.FieldData_Scalars).Scalars.Data.(*schemapb.ScalarField_DoubleData).DoubleData.GetData()[idx]
return sqltypes.MakeTrusted(sqltypes.Float64, strconv.AppendFloat(nil, v, 'g', -1, 64))
case schemapb.DataType_VarChar:
v := fieldData.Field.(*schemapb.FieldData_Scalars).Scalars.Data.(*schemapb.ScalarField_StringData).StringData.GetData()[idx]
return sqltypes.NewVarChar(v)
// TODO: vector.
default:
// TODO: should raise error here.
return sqltypes.NewInt32(1)
}
}
func NewDefaultExecutor(s types.ProxyComponent) Executor {
return &defaultExecutor{s: s}
}

View File

@ -0,0 +1,503 @@
package executor
import (
"context"
"testing"
"github.com/cockroachdb/errors"
"github.com/milvus-io/milvus-proto/go-api/schemapb"
"github.com/milvus-io/milvus-proto/go-api/commonpb"
"github.com/milvus-io/milvus-proto/go-api/milvuspb"
"github.com/milvus-io/milvus/internal/mocks"
"github.com/stretchr/testify/mock"
"github.com/stretchr/testify/assert"
"github.com/milvus-io/milvus/internal/mysqld/planner"
querypb "github.com/xelabs/go-mysqlstack/sqlparser/depends/query"
)
func Test_defaultExecutor_Run(t *testing.T) {
t.Run("not sql statements", func(t *testing.T) {
e := NewDefaultExecutor(nil)
plan := &planner.PhysicalPlan{
Node: planner.NewNodeConstant("20230306", planner.WithStringLiteral("20230306")),
}
_, err := e.Run(context.TODO(), plan)
assert.Error(t, err)
})
t.Run("multiple statements", func(t *testing.T) {
e := NewDefaultExecutor(nil)
stmts := []*planner.NodeSqlStatement{
planner.NewNodeSqlStatement("sql1"),
planner.NewNodeSqlStatement("sql2"),
}
plan := &planner.PhysicalPlan{
Node: planner.NewNodeSqlStatements(stmts, "sql1; sql2"),
}
_, err := e.Run(context.TODO(), plan)
assert.Error(t, err)
})
t.Run("normal case", func(t *testing.T) {
s := mocks.NewProxyComponent(t)
res := &milvuspb.QueryResults{
Status: &commonpb.Status{},
FieldsData: []*schemapb.FieldData{
{
Type: schemapb.DataType_Int64,
FieldName: "field",
Field: &schemapb.FieldData_Scalars{
Scalars: &schemapb.ScalarField{
Data: &schemapb.ScalarField_LongData{
LongData: &schemapb.LongArray{
Data: []int64{1, 2, 3, 4},
},
},
},
},
},
},
CollectionName: "test",
}
s.On("Query",
mock.Anything, // context.Context
mock.Anything, // *milvuspb.QueryRequest
).Return(res, nil)
e := NewDefaultExecutor(s)
stmts := []*planner.NodeSqlStatement{
planner.NewNodeSqlStatement("", planner.WithDmlStatement(
planner.NewNodeDmlStatement("", planner.WithSelectStatement(
planner.NewNodeSelectStatement("", planner.WithSimpleSelect(
planner.NewNodeSimpleSelect("", planner.WithQuery(
planner.NewNodeQuerySpecification("",
nil,
[]*planner.NodeSelectElement{
planner.NewNodeSelectElement("", planner.WithFullColumnName(
planner.NewNodeFullColumnName("", "field"))),
}, planner.WithFrom(planner.NewNodeFromClause("",
[]*planner.NodeTableSource{
planner.NewNodeTableSource("", planner.WithTableName("test")),
},
planner.WithWhere(planner.NewNodeExpression("", planner.WithPredicate(
planner.NewNodePredicate("", planner.WithNodeBinaryComparisonPredicate(
planner.NewNodeBinaryComparisonPredicate("",
planner.NewNodePredicate("", planner.WithNodeExpressionAtomPredicate(
planner.NewNodeExpressionAtomPredicate("",
planner.NewNodeExpressionAtom("", planner.ExpressionAtomWithFullColumnName(
planner.NewNodeFullColumnName("", "field")))))),
planner.NewNodePredicate("", planner.WithNodeExpressionAtomPredicate(
planner.NewNodeExpressionAtomPredicate("",
planner.NewNodeExpressionAtom("", planner.ExpressionAtomWithFullColumnName(
planner.NewNodeFullColumnName("", "field")))))),
planner.ComparisonOperatorEqual),
),
)),
),
),
),
),
),
)),
)),
)),
)),
}
plan := &planner.PhysicalPlan{
Node: planner.NewNodeSqlStatements(stmts, ""),
}
sqlRes, err := e.Run(context.TODO(), plan)
assert.NoError(t, err)
assert.Equal(t, 1, len(sqlRes.Fields))
assert.Equal(t, 4, len(sqlRes.Rows))
assert.Equal(t, "field", sqlRes.Fields[0].Name)
assert.Equal(t, querypb.Type_INT64, sqlRes.Fields[0].Type)
assert.Equal(t, 1, len(sqlRes.Rows[0]))
assert.Equal(t, querypb.Type_INT64, sqlRes.Rows[0][0].Type())
})
}
func Test_defaultExecutor_dispatch(t *testing.T) {
t.Run("not dml", func(t *testing.T) {
e := NewDefaultExecutor(nil).(*defaultExecutor)
n := planner.NewNodeSqlStatement("")
_, err := e.dispatch(context.TODO(), n)
assert.Error(t, err)
})
}
func Test_defaultExecutor_dispatchDmlStatement(t *testing.T) {
t.Run("not select", func(t *testing.T) {
e := NewDefaultExecutor(nil).(*defaultExecutor)
n := planner.NewNodeDmlStatement("")
_, err := e.dispatchDmlStatement(context.TODO(), n)
assert.Error(t, err)
})
}
func Test_defaultExecutor_execSelect(t *testing.T) {
t.Run("not simple select", func(t *testing.T) {
e := NewDefaultExecutor(nil).(*defaultExecutor)
n := planner.NewNodeSelectStatement("")
_, err := e.execSelect(context.TODO(), n)
assert.Error(t, err)
})
t.Run("lock clause, not supported", func(t *testing.T) {
e := NewDefaultExecutor(nil).(*defaultExecutor)
n := planner.NewNodeSelectStatement("", planner.WithSimpleSelect(
planner.NewNodeSimpleSelect("", planner.WithLockClause(
planner.NewNodeLockClause("", planner.LockClauseOptionForUpdate)))))
_, err := e.execSelect(context.TODO(), n)
assert.Error(t, err)
})
t.Run("not query", func(t *testing.T) {
e := NewDefaultExecutor(nil).(*defaultExecutor)
n := planner.NewNodeSelectStatement("", planner.WithSimpleSelect(
planner.NewNodeSimpleSelect("")))
_, err := e.execSelect(context.TODO(), n)
assert.Error(t, err)
})
t.Run("pagination, not supported", func(t *testing.T) {
e := NewDefaultExecutor(nil).(*defaultExecutor)
n := planner.NewNodeSelectStatement("", planner.WithSimpleSelect(
planner.NewNodeSimpleSelect("", planner.WithQuery(
planner.NewNodeQuerySpecification("",
nil,
nil,
planner.WithLimit(planner.NewNodeLimitClause("", 1, 2)))))))
_, err := e.execSelect(context.TODO(), n)
assert.Error(t, err)
})
t.Run("select specs, not supported", func(t *testing.T) {
e := NewDefaultExecutor(nil).(*defaultExecutor)
n := planner.NewNodeSelectStatement("", planner.WithSimpleSelect(
planner.NewNodeSimpleSelect("", planner.WithQuery(
planner.NewNodeQuerySpecification("",
[]*planner.NodeSelectSpec{
planner.NewNodeSelectSpec(""),
},
nil)))))
_, err := e.execSelect(context.TODO(), n)
assert.Error(t, err)
})
t.Run("no from clause", func(t *testing.T) {
e := NewDefaultExecutor(nil).(*defaultExecutor)
n := planner.NewNodeSelectStatement("", planner.WithSimpleSelect(
planner.NewNodeSimpleSelect("", planner.WithQuery(
planner.NewNodeQuerySpecification("",
nil,
nil)))))
_, err := e.execSelect(context.TODO(), n)
assert.Error(t, err)
})
t.Run("no table source", func(t *testing.T) {
e := NewDefaultExecutor(nil).(*defaultExecutor)
n := planner.NewNodeSelectStatement("", planner.WithSimpleSelect(
planner.NewNodeSimpleSelect("", planner.WithQuery(
planner.NewNodeQuerySpecification("",
nil,
nil,
planner.WithFrom(planner.NewNodeFromClause("", nil)))))))
_, err := e.execSelect(context.TODO(), n)
assert.Error(t, err)
})
t.Run("multiple table source", func(t *testing.T) {
e := NewDefaultExecutor(nil).(*defaultExecutor)
n := planner.NewNodeSelectStatement("", planner.WithSimpleSelect(
planner.NewNodeSimpleSelect("", planner.WithQuery(
planner.NewNodeQuerySpecification("",
nil,
nil,
planner.WithFrom(planner.NewNodeFromClause("",
[]*planner.NodeTableSource{
planner.NewNodeTableSource(""),
planner.NewNodeTableSource(""),
})))))))
_, err := e.execSelect(context.TODO(), n)
assert.Error(t, err)
})
t.Run("target entry as alias, not supported", func(t *testing.T) {
e := NewDefaultExecutor(nil).(*defaultExecutor)
n := planner.NewNodeSelectStatement("", planner.WithSimpleSelect(
planner.NewNodeSimpleSelect("", planner.WithQuery(
planner.NewNodeQuerySpecification("",
nil,
[]*planner.NodeSelectElement{
planner.NewNodeSelectElement("", planner.WithFullColumnName(
planner.NewNodeFullColumnName("", "field", planner.FullColumnNameWithAlias("alias")))),
},
planner.WithFrom(planner.NewNodeFromClause("",
[]*planner.NodeTableSource{
planner.NewNodeTableSource("", planner.WithTableName("test")),
})))))))
_, err := e.execSelect(context.TODO(), n)
assert.Error(t, err)
})
t.Run("failed to execute count", func(t *testing.T) {
s := mocks.NewProxyComponent(t)
s.On("GetCollectionStatistics",
mock.Anything, // context.Context
mock.Anything, // *milvuspb.GetCollectionStatisticsRequest
).Return(nil, errors.New("error mock GetCollectionStatistics"))
e := NewDefaultExecutor(s).(*defaultExecutor)
n := planner.NewNodeSelectStatement("", planner.WithSimpleSelect(
planner.NewNodeSimpleSelect("", planner.WithQuery(
planner.NewNodeQuerySpecification("",
nil,
[]*planner.NodeSelectElement{
planner.NewNodeSelectElement("", planner.WithFunctionCall(
planner.NewNodeFunctionCall("", planner.WithAgg(
planner.NewNodeAggregateWindowedFunction("", planner.WithAggCount(
planner.NewNodeCount(""))))))),
},
planner.WithFrom(planner.NewNodeFromClause("",
[]*planner.NodeTableSource{
planner.NewNodeTableSource("", planner.WithTableName("test")),
})))))))
_, err := e.execSelect(context.TODO(), n)
assert.Error(t, err)
})
t.Run("count without filter", func(t *testing.T) {
s := mocks.NewProxyComponent(t)
s.On("GetCollectionStatistics",
mock.Anything, // context.Context
mock.Anything, // *milvuspb.GetCollectionStatisticsRequest
).Return(&milvuspb.GetCollectionStatisticsResponse{
Status: &commonpb.Status{},
Stats: []*commonpb.KeyValuePair{{Value: "2"}},
}, nil)
e := NewDefaultExecutor(s).(*defaultExecutor)
n := planner.NewNodeSelectStatement("", planner.WithSimpleSelect(
planner.NewNodeSimpleSelect("", planner.WithQuery(
planner.NewNodeQuerySpecification("",
nil,
[]*planner.NodeSelectElement{
planner.NewNodeSelectElement("", planner.WithFunctionCall(
planner.NewNodeFunctionCall("", planner.WithAgg(
planner.NewNodeAggregateWindowedFunction("", planner.WithAggCount(
planner.NewNodeCount(""))))))),
},
planner.WithFrom(planner.NewNodeFromClause("",
[]*planner.NodeTableSource{
planner.NewNodeTableSource("", planner.WithTableName("test")),
})))))))
res, err := e.execSelect(context.TODO(), n)
assert.NoError(t, err)
assert.Equal(t, 1, len(res.Fields))
assert.Equal(t, "count(*)", res.Fields[0].Name)
assert.Equal(t, querypb.Type_INT64, res.Fields[0].Type)
assert.Equal(t, 1, len(res.Rows))
assert.Equal(t, 1, len(res.Rows[0]))
assert.Equal(t, querypb.Type_INT64, res.Rows[0][0].Type())
})
t.Run("count with filter", func(t *testing.T) {
s := mocks.NewProxyComponent(t)
s.On("Query",
mock.Anything, // context.Context
mock.Anything, // *milvuspb.QueryRequest
).Return(&milvuspb.QueryResults{
Status: &commonpb.Status{},
FieldsData: []*schemapb.FieldData{
{
Field: &schemapb.FieldData_Scalars{
Scalars: &schemapb.ScalarField{
Data: &schemapb.ScalarField_LongData{
LongData: &schemapb.LongArray{
Data: []int64{1, 2, 3, 4},
},
},
},
},
},
},
}, nil)
e := NewDefaultExecutor(s).(*defaultExecutor)
n := planner.NewNodeSelectStatement("", planner.WithSimpleSelect(
planner.NewNodeSimpleSelect("", planner.WithQuery(
planner.NewNodeQuerySpecification("",
nil,
[]*planner.NodeSelectElement{
planner.NewNodeSelectElement("", planner.WithFunctionCall(
planner.NewNodeFunctionCall("", planner.WithAgg(
planner.NewNodeAggregateWindowedFunction("", planner.WithAggCount(
planner.NewNodeCount(""))))))),
},
planner.WithFrom(planner.NewNodeFromClause("",
[]*planner.NodeTableSource{
planner.NewNodeTableSource("", planner.WithTableName("test")),
},
planner.WithWhere(GenNodeExpression("field", 1, planner.ComparisonOperatorGreaterEqual)))))))))
res, err := e.execSelect(context.TODO(), n)
assert.NoError(t, err)
assert.Equal(t, 1, len(res.Fields))
assert.Equal(t, "count(*)", res.Fields[0].Name)
assert.Equal(t, querypb.Type_INT64, res.Fields[0].Type)
assert.Equal(t, 1, len(res.Rows))
assert.Equal(t, 1, len(res.Rows[0]))
assert.Equal(t, querypb.Type_INT64, res.Rows[0][0].Type())
})
t.Run("query without filter", func(t *testing.T) {
s := mocks.NewProxyComponent(t)
e := NewDefaultExecutor(s).(*defaultExecutor)
n := planner.NewNodeSelectStatement("", planner.WithSimpleSelect(
planner.NewNodeSimpleSelect("", planner.WithQuery(
planner.NewNodeQuerySpecification("",
nil,
[]*planner.NodeSelectElement{
planner.NewNodeSelectElement("", planner.WithFullColumnName(
planner.NewNodeFullColumnName("", "field"))),
},
planner.WithFrom(planner.NewNodeFromClause("",
[]*planner.NodeTableSource{
planner.NewNodeTableSource("", planner.WithTableName("test")),
})))))))
_, err := e.execSelect(context.TODO(), n)
assert.Error(t, err)
})
t.Run("failed to query with filter", func(t *testing.T) {
s := mocks.NewProxyComponent(t)
s.On("Query",
mock.Anything, // context.Context
mock.Anything, // *milvuspb.QueryRequest
).Return(nil, errors.New("error mock Query"))
e := NewDefaultExecutor(s).(*defaultExecutor)
n := planner.NewNodeSelectStatement("", planner.WithSimpleSelect(
planner.NewNodeSimpleSelect("", planner.WithQuery(
planner.NewNodeQuerySpecification("",
nil,
[]*planner.NodeSelectElement{
planner.NewNodeSelectElement("", planner.WithFullColumnName(
planner.NewNodeFullColumnName("", "field"))),
},
planner.WithFrom(planner.NewNodeFromClause("",
[]*planner.NodeTableSource{
planner.NewNodeTableSource("", planner.WithTableName("test")),
},
planner.WithWhere(GenNodeExpression("field", 100, planner.ComparisonOperatorEqual)))))))))
_, err := e.execSelect(context.TODO(), n)
assert.Error(t, err)
})
t.Run("query with filter", func(t *testing.T) {
s := mocks.NewProxyComponent(t)
res := &milvuspb.QueryResults{
Status: &commonpb.Status{},
FieldsData: []*schemapb.FieldData{
{
Type: schemapb.DataType_Int64,
FieldName: "field",
Field: &schemapb.FieldData_Scalars{
Scalars: &schemapb.ScalarField{
Data: &schemapb.ScalarField_LongData{
LongData: &schemapb.LongArray{
Data: []int64{1, 2, 3, 4},
},
},
},
},
},
},
CollectionName: "test",
}
s.On("Query",
mock.Anything, // context.Context
mock.Anything, // *milvuspb.QueryRequest
).Return(res, nil)
e := NewDefaultExecutor(s).(*defaultExecutor)
n := planner.NewNodeSelectStatement("", planner.WithSimpleSelect(
planner.NewNodeSimpleSelect("", planner.WithQuery(
planner.NewNodeQuerySpecification("",
nil,
[]*planner.NodeSelectElement{
planner.NewNodeSelectElement("", planner.WithFullColumnName(
planner.NewNodeFullColumnName("", "field"))),
},
planner.WithFrom(planner.NewNodeFromClause("",
[]*planner.NodeTableSource{
planner.NewNodeTableSource("", planner.WithTableName("test")),
},
planner.WithWhere(GenNodeExpression("field", 100, planner.ComparisonOperatorEqual)))))))))
sqlRes, err := e.execSelect(context.TODO(), n)
assert.NoError(t, err)
assert.Equal(t, 1, len(sqlRes.Fields))
assert.Equal(t, 4, len(sqlRes.Rows))
assert.Equal(t, "field", sqlRes.Fields[0].Name)
assert.Equal(t, querypb.Type_INT64, sqlRes.Fields[0].Type)
assert.Equal(t, 1, len(sqlRes.Rows[0]))
assert.Equal(t, querypb.Type_INT64, sqlRes.Rows[0][0].Type())
})
}
func Test_getOutputFieldsOrMatchCountRule(t *testing.T) {
t.Run("match count rule", func(t *testing.T) {
fl := []*planner.NodeSelectElement{
planner.NewNodeSelectElement("", planner.WithFunctionCall(
planner.NewNodeFunctionCall("", planner.WithAgg(
planner.NewNodeAggregateWindowedFunction("", planner.WithAggCount(
planner.NewNodeCount(""))))))),
}
_, match, err := getOutputFieldsOrMatchCountRule(fl)
assert.NoError(t, err)
assert.True(t, match)
})
t.Run("star *, not supported", func(t *testing.T) {
fl := []*planner.NodeSelectElement{
planner.NewNodeSelectElement("", planner.WithStar()),
}
_, _, err := getOutputFieldsOrMatchCountRule(fl)
assert.Error(t, err)
})
t.Run("combined", func(t *testing.T) {
fl := []*planner.NodeSelectElement{
planner.NewNodeSelectElement("", planner.WithFunctionCall(
planner.NewNodeFunctionCall("", planner.WithAgg(
planner.NewNodeAggregateWindowedFunction("", planner.WithAggCount(
planner.NewNodeCount(""))))))),
planner.NewNodeSelectElement("", planner.WithFullColumnName(
planner.NewNodeFullColumnName("", "field"))),
}
_, _, err := getOutputFieldsOrMatchCountRule(fl)
assert.Error(t, err)
})
t.Run("alias, not supported", func(t *testing.T) {
fl := []*planner.NodeSelectElement{
planner.NewNodeSelectElement("", planner.WithFullColumnName(
planner.NewNodeFullColumnName("", "field", planner.FullColumnNameWithAlias("alias")))),
}
_, _, err := getOutputFieldsOrMatchCountRule(fl)
assert.Error(t, err)
})
t.Run("normal case", func(t *testing.T) {
fl := []*planner.NodeSelectElement{
planner.NewNodeSelectElement("", planner.WithFullColumnName(
planner.NewNodeFullColumnName("", "field1"))),
planner.NewNodeSelectElement("", planner.WithFullColumnName(
planner.NewNodeFullColumnName("", "field2"))),
}
outputFields, match, err := getOutputFieldsOrMatchCountRule(fl)
assert.NoError(t, err)
assert.False(t, match)
assert.ElementsMatch(t, []string{"field1", "field2"}, outputFields)
})
}

View File

@ -0,0 +1,22 @@
package executor
import "github.com/milvus-io/milvus/internal/mysqld/planner"
func GenNodeExpression(field string, c int64, op planner.ComparisonOperator) *planner.NodeExpression {
n := planner.NewNodeExpression("", planner.WithPredicate(
planner.NewNodePredicate("", planner.WithNodeBinaryComparisonPredicate(
planner.NewNodeBinaryComparisonPredicate("",
planner.NewNodePredicate("", planner.WithNodeExpressionAtomPredicate(
planner.NewNodeExpressionAtomPredicate("",
planner.NewNodeExpressionAtom("", planner.ExpressionAtomWithFullColumnName(
planner.NewNodeFullColumnName("", field)))))),
planner.NewNodePredicate("", planner.WithNodeExpressionAtomPredicate(
planner.NewNodeExpressionAtomPredicate("",
planner.NewNodeExpressionAtom("", planner.ExpressionAtomWithConstant(
planner.NewNodeConstant("", planner.WithDecimalLiteral(c))))))),
op),
),
)),
)
return n
}

View File

@ -0,0 +1,40 @@
package mysqld
import (
"github.com/milvus-io/milvus/internal/mysqld/executor"
"github.com/milvus-io/milvus/internal/mysqld/optimizer"
parserimpl "github.com/milvus-io/milvus/internal/mysqld/parser"
"github.com/milvus-io/milvus/internal/mysqld/parser/antlrparser"
"github.com/milvus-io/milvus/internal/types"
)
type sqlFactory interface {
NewParser() parserimpl.Parser
NewOptimizer() (optimizer.RuleBasedOptimizer, optimizer.CostBasedOptimizer)
NewCompiler() executor.Compiler
NewExecutor() executor.Executor
}
type defaultFactory struct {
s types.ProxyComponent
}
func (f defaultFactory) NewParser() parserimpl.Parser {
return antlrparser.NewAntlrParser()
}
func (f defaultFactory) NewOptimizer() (optimizer.RuleBasedOptimizer, optimizer.CostBasedOptimizer) {
return optimizer.NewDefaultRBO(), optimizer.NewDefaultCBO()
}
func (f defaultFactory) NewCompiler() executor.Compiler {
return executor.NewDefaultCompiler()
}
func (f defaultFactory) NewExecutor() executor.Executor {
return executor.NewDefaultExecutor(f.s)
}
func newDefaultFactory(s types.ProxyComponent) sqlFactory {
return &defaultFactory{s: s}
}

122
internal/mysqld/handler.go Normal file
View File

@ -0,0 +1,122 @@
package mysqld
import (
"context"
"fmt"
"strings"
"github.com/milvus-io/milvus/internal/log"
"github.com/milvus-io/milvus/internal/types"
"github.com/xelabs/go-mysqlstack/driver"
"github.com/xelabs/go-mysqlstack/sqlparser/depends/query"
querypb "github.com/xelabs/go-mysqlstack/sqlparser/depends/query"
"github.com/xelabs/go-mysqlstack/sqlparser/depends/sqltypes"
)
type handler struct {
s types.ProxyComponent
}
func (h *handler) ServerVersion() string {
return "Milvus"
}
func (h *handler) SetServerVersion() {
}
func (h *handler) NewSession(session *driver.Session) {
}
func (h *handler) SessionInc(session *driver.Session) {
}
func (h *handler) SessionDec(session *driver.Session) {
}
func (h *handler) SessionClosed(session *driver.Session) {
}
func (h *handler) SessionCheck(session *driver.Session) error {
return nil
}
func (h *handler) AuthCheck(session *driver.Session) error {
return nil
}
func (h *handler) ComInitDB(session *driver.Session, database string) error {
return nil
}
// ComQuery TODO: investigate how bindVariables work.
func (h *handler) ComQuery(session *driver.Session, query string, bindVariables map[string]*query.BindVariable, callback func(*sqltypes.Result) error) error {
if err := h.handleSpecialQuery(session, query, bindVariables, callback); err == nil {
return nil
}
f := newDefaultFactory(h.s)
parser := f.NewParser()
logicalPlan, warns, err := parser.Parse(query)
if err != nil {
return err
}
logWarns(warns)
rbo, cbo := f.NewOptimizer()
optimizedLogicalPlan := rbo.Optimize(logicalPlan)
compiler := f.NewCompiler()
physicalPlan, err := compiler.Compile(optimizedLogicalPlan)
if err != nil {
return err
}
optimizedPhysicalPlan := cbo.Optimize(physicalPlan)
e := f.NewExecutor()
res, err := e.Run(context.TODO(), optimizedPhysicalPlan)
if err != nil {
return err
}
return callback(res)
}
func (h *handler) handleSpecialQuery(session *driver.Session, query string, bindVariables map[string]*query.BindVariable, callback func(*sqltypes.Result) error) error {
words := strings.Fields(query)
// select @@version_comment limit 1
if len(words) == 4 &&
strings.ToLower(words[0]) == "select" &&
strings.ToLower(words[1]) == "@@version_comment" &&
strings.ToLower(words[2]) == "limit" &&
strings.ToLower(words[3]) == "1" {
res := &sqltypes.Result{
Fields: []*querypb.Field{
{
Name: "@@version_comment",
Type: querypb.Type_VARCHAR,
},
},
Rows: [][]sqltypes.Value{
{
sqltypes.NewVarChar("TODO"),
},
},
}
return callback(res)
}
return fmt.Errorf("unsupported sql: %s", query)
}
func logWarns(warns []error) {
for _, warn := range warns {
log.Info(warn.Error())
}
}
func newHandler(s types.ProxyComponent) driver.Handler {
h := &handler{s: s}
return h
}

View File

@ -0,0 +1,17 @@
package optimizer
import "github.com/milvus-io/milvus/internal/mysqld/planner"
type CostBasedOptimizer interface {
Optimize(plan *planner.PhysicalPlan) *planner.PhysicalPlan
}
type defaultCBO struct{}
func (o defaultCBO) Optimize(plan *planner.PhysicalPlan) *planner.PhysicalPlan {
return plan
}
func NewDefaultCBO() CostBasedOptimizer {
return &defaultCBO{}
}

View File

@ -0,0 +1,19 @@
package optimizer
import (
"github.com/milvus-io/milvus/internal/mysqld/planner"
)
type RuleBasedOptimizer interface {
Optimize(plan *planner.LogicalPlan) *planner.LogicalPlan
}
type defaultRBO struct{}
func (o defaultRBO) Optimize(plan *planner.LogicalPlan) *planner.LogicalPlan {
return plan
}
func NewDefaultRBO() RuleBasedOptimizer {
return &defaultRBO{}
}

View File

@ -0,0 +1,832 @@
package antlrparser
import (
"fmt"
"strconv"
"github.com/milvus-io/milvus/internal/mysqld/planner"
"github.com/antlr/antlr4/runtime/Go/antlr/v4"
parsergen "github.com/milvus-io/milvus/internal/mysqld/parser/antlrparser/parser"
)
type AstBuilder struct {
parsergen.BaseMySqlParserVisitor
}
type AstBuilderOption func(*AstBuilder)
func (v *AstBuilder) apply(opts ...AstBuilderOption) {
for _, opt := range opts {
opt(v)
}
}
func (v *AstBuilder) VisitRoot(ctx *parsergen.RootContext) interface{} {
return ctx.SqlStatements().Accept(v)
}
func (v *AstBuilder) VisitSqlStatements(ctx *parsergen.SqlStatementsContext) interface{} {
allSqlStatementsCtx := ctx.AllSqlStatement()
sqlStatements := make([]*planner.NodeSqlStatement, 0, len(allSqlStatementsCtx))
for _, sqlStatementCtx := range allSqlStatementsCtx {
r := sqlStatementCtx.Accept(v)
if err := GetError(r); err != nil {
return err
}
n := GetSqlStatement(r)
if n == nil {
return fmt.Errorf("failed to parse sql statement: %s", sqlStatementCtx.GetText())
}
sqlStatements = append(sqlStatements, n)
}
return planner.NewNodeSqlStatements(sqlStatements, GetOriginalText(ctx))
}
func (v *AstBuilder) VisitSqlStatement(ctx *parsergen.SqlStatementContext) interface{} {
dmlStatement := ctx.DmlStatement()
if dmlStatement == nil {
return fmt.Errorf("sql statement only support dml statement now: %s", GetOriginalText(ctx))
}
r := dmlStatement.Accept(v)
if err := GetError(r); err != nil {
return err
}
n := GetDmlStatement(r)
if n == nil {
return fmt.Errorf("failed to parse dml statement: %s", dmlStatement.GetText())
}
return planner.NewNodeSqlStatement(GetOriginalText(ctx), planner.WithDmlStatement(n))
}
func (v *AstBuilder) VisitEmptyStatement_(ctx *parsergen.EmptyStatement_Context) interface{} {
// Should not be visited.
return nil
}
func (v *AstBuilder) VisitDmlStatement(ctx *parsergen.DmlStatementContext) interface{} {
selectStatement := ctx.SelectStatement()
if selectStatement == nil {
return fmt.Errorf("dml statement only support select statement now: %s", GetOriginalText(ctx))
}
r := selectStatement.Accept(v)
if err := GetError(r); err != nil {
return err
}
n := GetSelectStatement(r)
if n == nil {
return fmt.Errorf("failed to parse select statement: %s", selectStatement.GetText())
}
return planner.NewNodeDmlStatement(GetOriginalText(ctx), planner.WithSelectStatement(n))
}
func (v *AstBuilder) VisitSimpleSelect(ctx *parsergen.SimpleSelectContext) interface{} {
var opts []planner.NodeSimpleSelectOption
querySpecificationCtx := ctx.QuerySpecification()
if querySpecificationCtx == nil {
return fmt.Errorf("simple select only support query specification now: %s", GetOriginalText(ctx))
}
r := querySpecificationCtx.Accept(v)
if err := GetError(r); err != nil {
return err
}
n := GetQuerySpecification(r)
if n == nil {
return fmt.Errorf("failed to parse query specification: %s", GetOriginalText(querySpecificationCtx))
}
opts = append(opts, planner.WithQuery(n))
lockClauseCtx := ctx.LockClause()
if lockClauseCtx != nil {
r := lockClauseCtx.Accept(v)
if err := GetError(r); err != nil {
return err
}
if n := GetLockClause(r); n != nil {
opts = append(opts, planner.WithLockClause(n))
}
}
text := GetOriginalText(ctx)
nodeSimpleSelect := planner.NewNodeSimpleSelect(text, opts...)
return planner.NewNodeSelectStatement(text, planner.WithSimpleSelect(nodeSimpleSelect))
}
func (v *AstBuilder) VisitLockClause(ctx *parsergen.LockClauseContext) interface{} {
//o := planner.LockClauseOptionUnknown
//text := GetOriginalText(ctx)
//if CaseInsensitiveEqual(text, planner.LockClauseOption_ForUpdate_Str) {
// o = planner.LockClauseOptionForUpdate
//} else if CaseInsensitiveEqual(text, planner.LockClauseOption_LockInShareMode_Str) {
// o = planner.LockClauseOptionLockInShareMode
//}
//return planner.NewNodeLockClause(text, o)
return fmt.Errorf("lock clause is not supported: %s", GetOriginalText(ctx))
}
func (v *AstBuilder) VisitQuerySpecification(ctx *parsergen.QuerySpecificationContext) interface{} {
allSelectSpecCtx := ctx.AllSelectSpec()
selectSpecs := make([]*planner.NodeSelectSpec, 0, len(allSelectSpecCtx))
for _, selectSpecCtx := range allSelectSpecCtx {
r := selectSpecCtx.Accept(v)
if err := GetError(r); err != nil {
return err
}
if n := GetSelectSpec(r); n != nil {
selectSpecs = append(selectSpecs, n)
}
}
selectElementsCtx := ctx.SelectElements()
allSelectElementsCtx := selectElementsCtx.(*parsergen.SelectElementsContext).AllSelectElement()
selectElements := make([]*planner.NodeSelectElement, 0, len(allSelectElementsCtx))
if star := selectElementsCtx.GetStar(); star != nil {
selectElements = append(selectElements, planner.NewNodeSelectElement(star.GetText(), planner.WithStar()))
}
for _, selectElementCtx := range allSelectElementsCtx {
r := selectElementCtx.Accept(v)
if err := GetError(r); err != nil {
return err
}
if n := GetSelectElement(r); n != nil {
selectElements = append(selectElements, n)
}
}
var opts []planner.NodeQuerySpecificationOption
fromCtx := ctx.FromClause()
if fromCtx != nil {
r := fromCtx.Accept(v)
if err := GetError(r); err != nil {
return err
}
if n := GetFromClause(r); n != nil {
opts = append(opts, planner.WithFrom(n))
}
}
limitCtx := ctx.LimitClause()
if limitCtx != nil {
r := limitCtx.Accept(v)
if err := GetError(r); err != nil {
return err
}
if n := GetLimitClause(r); n != nil {
opts = append(opts, planner.WithLimit(n))
}
}
return planner.NewNodeQuerySpecification(GetOriginalText(ctx), selectSpecs, selectElements, opts...)
}
func (v *AstBuilder) VisitSelectSpec(ctx *parsergen.SelectSpecContext) interface{} {
return fmt.Errorf("select spec is not supported: %s", GetOriginalText(ctx))
}
func (v *AstBuilder) VisitSelectElements(ctx *parsergen.SelectElementsContext) interface{} {
// Should not be visited.
return nil
}
func (v *AstBuilder) VisitSelectColumnElement(ctx *parsergen.SelectColumnElementContext) interface{} {
var opts []planner.NodeFullColumnNameOption
asCtx := ctx.AS()
uidCtx := ctx.Uid()
if asCtx != nil && uidCtx != nil {
r := uidCtx.Accept(v)
if err := GetError(r); err != nil {
return err
}
if alias, ok := r.(string); ok {
opts = append(opts, planner.FullColumnNameWithAlias(alias))
}
}
if asCtx == nil && uidCtx != nil {
return fmt.Errorf("invalid alias of column: %s", GetOriginalText(ctx))
}
r := ctx.FullColumnName().Accept(v)
if err := GetError(r); err != nil {
return err
}
s := r.(string)
text := GetOriginalText(ctx)
n := planner.NewNodeFullColumnName(text, s, opts...)
return planner.NewNodeSelectElement(text, planner.WithFullColumnName(n))
}
func (v *AstBuilder) VisitSelectFunctionElement(ctx *parsergen.SelectFunctionElementContext) interface{} {
var opts []planner.NodeFunctionCallOption
asCtx := ctx.AS()
uidCtx := ctx.Uid()
if asCtx != nil && uidCtx != nil {
r := uidCtx.Accept(v)
if err := GetError(r); err != nil {
return err
}
if alias, ok := r.(string); ok {
opts = append(opts, planner.FunctionCallWithAlias(alias))
}
}
if asCtx == nil && uidCtx != nil {
return fmt.Errorf("invalid alias of function call: %s", ctx.GetText())
}
r := ctx.FunctionCall().Accept(v)
if err := GetError(r); err != nil {
return err
}
if n := GetAggregateWindowedFunction(r); n != nil {
opts = append(opts, planner.WithAgg(n))
}
text := GetOriginalText(ctx)
n := planner.NewNodeFunctionCall(text, opts...)
return planner.NewNodeSelectElement(text, planner.WithFunctionCall(n))
}
func (v *AstBuilder) VisitFromClause(ctx *parsergen.FromClauseContext) interface{} {
text := GetOriginalText(ctx)
tableSourcesCtx := ctx.TableSources().(*parsergen.TableSourcesContext)
allTableSourcesCtx := tableSourcesCtx.AllTableSource()
tableSources := make([]*planner.NodeTableSource, 0, len(allTableSourcesCtx))
for _, tableSourceCtx := range allTableSourcesCtx {
r := tableSourceCtx.Accept(v)
if err := GetError(r); err != nil {
return err
}
if n := GetTableSource(r); n != nil {
tableSources = append(tableSources, n)
}
}
var opts []planner.NodeFromClauseOption
whereCtx := ctx.Expression()
if whereCtx != nil {
r := whereCtx.Accept(v)
if err := GetError(r); err != nil {
return err
}
if n := GetExpression(r); n != nil {
opts = append(opts, planner.WithWhere(n))
}
}
return planner.NewNodeFromClause(text, tableSources, opts...)
}
func (v *AstBuilder) VisitTableSources(ctx *parsergen.TableSourcesContext) interface{} {
// Should not be visited.
return nil
}
func (v *AstBuilder) VisitTableSourceBase(ctx *parsergen.TableSourceBaseContext) interface{} {
text := GetOriginalText(ctx)
tableNameCtx := ctx.TableName()
r := tableNameCtx.Accept(v)
if err := GetError(r); err != nil {
return err
}
s, ok := r.(string)
if !ok {
return fmt.Errorf("not supported table source: %s", text)
}
return planner.NewNodeTableSource(text, planner.WithTableName(s))
}
func (v *AstBuilder) VisitLimitClause(ctx *parsergen.LimitClauseContext) interface{} {
text := GetOriginalText(ctx)
offset, limit := int64(0), int64(0)
getInt := func(tree antlr.ParseTree) (int64, error) {
r := tree.Accept(v)
if err := GetError(r); err != nil {
return 0, err
}
return r.(int64), nil
}
offsetCtx := ctx.GetOffset()
if offsetCtx != nil {
i, err := getInt(offsetCtx)
if err != nil {
return err
}
offset = i
}
limitCtx := ctx.GetLimit()
i, err := getInt(limitCtx)
if err != nil {
return err
}
limit = i
return planner.NewNodeLimitClause(text, limit, offset)
}
func (v *AstBuilder) VisitLimitClauseAtom(ctx *parsergen.LimitClauseAtomContext) interface{} {
text := GetOriginalText(ctx)
decimalLiteralCtx := ctx.DecimalLiteral()
if decimalLiteralCtx == nil {
return fmt.Errorf("limit only support literal now: %s", text)
}
return decimalLiteralCtx.Accept(v)
}
func (v *AstBuilder) VisitFullId(ctx *parsergen.FullIdContext) interface{} {
return GetOriginalText(ctx)
}
func (v *AstBuilder) VisitTableName(ctx *parsergen.TableNameContext) interface{} {
return GetOriginalText(ctx)
}
func (v *AstBuilder) VisitFullColumnName(ctx *parsergen.FullColumnNameContext) interface{} {
return GetOriginalText(ctx)
}
func (v *AstBuilder) VisitCollationName(ctx *parsergen.CollationNameContext) interface{} {
return GetOriginalText(ctx)
}
func (v *AstBuilder) VisitUid(ctx *parsergen.UidContext) interface{} {
return GetOriginalText(ctx)
}
func (v *AstBuilder) VisitSimpleId(ctx *parsergen.SimpleIdContext) interface{} {
return GetOriginalText(ctx)
}
func (v *AstBuilder) VisitDottedId(ctx *parsergen.DottedIdContext) interface{} {
return GetOriginalText(ctx)
}
func (v *AstBuilder) VisitDecimalLiteral(ctx *parsergen.DecimalLiteralContext) interface{} {
if decimalCtx := ctx.DECIMAL_LITERAL(); decimalCtx != nil {
i, err := strconv.Atoi(decimalCtx.GetText())
if err != nil {
return err
}
return int64(i)
}
if zeroCtx := ctx.ZERO_DECIMAL(); zeroCtx != nil {
return int64(0)
}
if oneCtx := ctx.ONE_DECIMAL(); oneCtx != nil {
return int64(1)
}
if twoCtx := ctx.TWO_DECIMAL(); twoCtx != nil {
return int64(2)
}
if realCtx := ctx.REAL_LITERAL(); realCtx != nil {
f, err := processRealCtx(realCtx)
if err != nil {
return err
}
return f
}
return nil
}
func processRealCtx(n antlr.TerminalNode) (float64, error) {
f, err := strconv.ParseFloat(n.GetText(), 64)
if err != nil {
return 0.0, err
}
return f, nil
}
func (v *AstBuilder) VisitStringLiteral(ctx *parsergen.StringLiteralContext) interface{} {
return GetOriginalText(ctx)
}
func (v *AstBuilder) VisitBooleanLiteral(ctx *parsergen.BooleanLiteralContext) interface{} {
return ctx.TRUE() != nil
}
func (v *AstBuilder) VisitHexadecimalLiteral(ctx *parsergen.HexadecimalLiteralContext) interface{} {
text := GetOriginalText(ctx)
i, err := strconv.ParseInt(text, 16, 64)
if err != nil {
return err
}
return i
}
func (v *AstBuilder) VisitConstant(ctx *parsergen.ConstantContext) interface{} {
if stringLiteralCtx := ctx.StringLiteral(); stringLiteralCtx != nil {
return stringLiteralCtx.Accept(v)
}
if decimalLiteralCtx := ctx.DecimalLiteral(); decimalLiteralCtx != nil {
decimal := decimalLiteralCtx.Accept(v)
if err := GetError(decimal); err != nil {
return err
}
if ctx.MINUS() != nil {
switch realType := decimal.(type) {
case int:
return -realType
case int32:
return -realType
case int64:
return -realType
case float32:
return -realType
case float64:
return -realType
default:
return fmt.Errorf("invalid data type: %s", decimalLiteralCtx.GetText())
}
}
return decimal
}
if hexadecimalLiteralCtx := ctx.HexadecimalLiteral(); hexadecimalLiteralCtx != nil {
return hexadecimalLiteralCtx.Accept(v)
}
if realCtx := ctx.REAL_LITERAL(); realCtx != nil {
f, err := processRealCtx(realCtx)
if err != nil {
return err
}
return f
}
return nil
}
func (v *AstBuilder) VisitExpressions(ctx *parsergen.ExpressionsContext) interface{} {
text := GetOriginalText(ctx)
expressionsCtx := ctx.AllExpression()
expressions := make([]*planner.NodeExpression, 0, len(expressionsCtx))
for _, expressionCtx := range expressionsCtx {
n, err := v.getExpression(expressionCtx)
if err != nil {
return err
}
if n == nil {
return fmt.Errorf("failed to parse expression: %s", GetOriginalText(expressionCtx))
}
expressions = append(expressions, n)
}
return planner.NewNodeExpressions(text, expressions)
}
func (v *AstBuilder) VisitAggregateFunctionCall(ctx *parsergen.AggregateFunctionCallContext) interface{} {
r := ctx.AggregateWindowedFunction().Accept(v)
if err := GetError(r); err != nil {
return err
}
if n := GetCount(r); n != nil {
return planner.NewNodeAggregateWindowedFunction(GetOriginalText(ctx), planner.WithAggCount(n))
}
return nil
}
func (v *AstBuilder) VisitAggregateWindowedFunction(ctx *parsergen.AggregateWindowedFunctionContext) interface{} {
text := GetOriginalText(ctx)
return planner.NewNodeCount(text)
}
func (v *AstBuilder) getPredicate(tree antlr.ParseTree) (*planner.NodePredicate, error) {
r := tree.Accept(v)
if err := GetError(r); err != nil {
return nil, err
}
return GetPredicate(r), nil
}
func (v *AstBuilder) VisitIsExpression(ctx *parsergen.IsExpressionContext) interface{} {
text := GetOriginalText(ctx)
testValue := planner.TestValueUnknown
if ctx.TRUE() != nil {
testValue = planner.TestValueTrue
}
if ctx.FALSE() != nil {
testValue = planner.TestValueFalse
}
op := planner.IsOperatorIs
if ctx.NOT() != nil {
op = planner.IsOperatorIsNot
}
n, err := v.getPredicate(ctx.Predicate())
if err != nil {
return err
}
if n == nil {
return fmt.Errorf("failed to parse [is expression]: %s", text)
}
isExpr := planner.NewNodeIsExpression(text, n, testValue, op)
return planner.NewNodeExpression(text, planner.WithIsExpr(isExpr))
}
func (v *AstBuilder) getExpression(tree antlr.ParseTree) (*planner.NodeExpression, error) {
r := tree.Accept(v)
if err := GetError(r); err != nil {
return nil, err
}
return GetExpression(r), nil
}
func (v *AstBuilder) VisitNotExpression(ctx *parsergen.NotExpressionContext) interface{} {
text := GetOriginalText(ctx)
expressionCtx := ctx.Expression()
n, err := v.getExpression(expressionCtx)
if err != nil {
return err
}
if n == nil {
return fmt.Errorf("failed to parse [not expression]: %s", text)
}
notExpr := planner.NewNodeNotExpression(text, n)
return planner.NewNodeExpression(text, planner.WithNotExpr(notExpr))
}
func (v *AstBuilder) VisitLogicalExpression(ctx *parsergen.LogicalExpressionContext) interface{} {
text := GetOriginalText(ctx)
op := ctx.LogicalOperator().Accept(v).(planner.LogicalOperator)
left, right := ctx.Expression(0), ctx.Expression(1)
leftExpr, err := v.getExpression(left)
if err != nil {
return err
}
if leftExpr == nil {
return fmt.Errorf("failed to parse left expr: %s", left.GetText())
}
rightExpr, err := v.getExpression(right)
if err != nil {
return err
}
if rightExpr == nil {
return fmt.Errorf("failed to parse right expr: %s", right.GetText())
}
logicalExpr := planner.NewNodeLogicalExpression(text, leftExpr, rightExpr, op)
return planner.NewNodeExpression(text, planner.WithLogicalExpr(logicalExpr))
}
func (v *AstBuilder) VisitPredicateExpression(ctx *parsergen.PredicateExpressionContext) interface{} {
text := GetOriginalText(ctx)
predicateCtx := ctx.Predicate()
predicate, err := v.getPredicate(predicateCtx)
if err != nil {
return err
}
if predicate == nil {
return fmt.Errorf("failed to parse predicate expression: %s", GetOriginalText(predicateCtx))
}
return planner.NewNodeExpression(text, planner.WithPredicate(predicate))
}
func (v *AstBuilder) getExpressionAtom(tree antlr.ParseTree) (*planner.NodeExpressionAtom, error) {
r := tree.Accept(v)
if err := GetError(r); err != nil {
return nil, err
}
return GetExpressionAtom(r), nil
}
func (v *AstBuilder) VisitExpressionAtomPredicate(ctx *parsergen.ExpressionAtomPredicateContext) interface{} {
text := GetOriginalText(ctx)
if ctx.LOCAL_ID() != nil || ctx.VAR_ASSIGN() != nil {
return fmt.Errorf("assignment not supported: %s", text)
}
n, err := v.getExpressionAtom(ctx.ExpressionAtom())
if err != nil {
return err
}
if n == nil {
return fmt.Errorf("failed to parse expression atom predicate: %s", text)
}
expr := planner.NewNodeExpressionAtomPredicate(text, n)
return planner.NewNodePredicate(text, planner.WithNodeExpressionAtomPredicate(expr))
}
func (v *AstBuilder) VisitBinaryComparisonPredicate(ctx *parsergen.BinaryComparisonPredicateContext) interface{} {
text := GetOriginalText(ctx)
op := ctx.ComparisonOperator().Accept(v).(planner.ComparisonOperator)
leftCtx, rightCtx := ctx.GetLeft(), ctx.GetRight()
left, err := v.getPredicate(leftCtx)
if err != nil {
return err
}
if left == nil {
return fmt.Errorf("failed to parse left predicate: %s", GetOriginalText(leftCtx))
}
right, err := v.getPredicate(rightCtx)
if err != nil {
return err
}
if right == nil {
return fmt.Errorf("failed to parse right predicate: %s", GetOriginalText(rightCtx))
}
expr := planner.NewNodeBinaryComparisonPredicate(text, left, right, op)
return planner.NewNodePredicate(text, planner.WithNodeBinaryComparisonPredicate(expr))
}
func (v *AstBuilder) VisitInPredicate(ctx *parsergen.InPredicateContext) interface{} {
text := GetOriginalText(ctx)
op := planner.InOperatorIn
if ctx.NOT() != nil {
op = planner.InOperatorNotIn
}
predicateCtx := ctx.Predicate()
n, err := v.getPredicate(predicateCtx)
if err != nil {
return err
}
if n == nil {
return fmt.Errorf("failed to parse left in predicate: %s", GetOriginalText(predicateCtx))
}
expressionsCtx := ctx.Expressions()
r := expressionsCtx.Accept(v)
if err := GetError(r); err != nil {
return err
}
exprs := GetExpressions(r)
if exprs == nil {
return fmt.Errorf("failed to parse in expressions: %s", GetOriginalText(expressionsCtx))
}
expr := planner.NewNodeInPredicate(text, n, exprs, op)
return planner.NewNodePredicate(text, planner.WithInPredicate(expr))
}
func (v *AstBuilder) VisitConstantExpressionAtom(ctx *parsergen.ConstantExpressionAtomContext) interface{} {
text := GetOriginalText(ctx)
constantCtx := ctx.Constant().(*parsergen.ConstantContext)
r := constantCtx.Accept(v)
if err := GetError(r); err != nil {
return err
}
var opts []planner.NodeConstantOption
switch t := r.(type) {
case int64:
opts = append(opts, planner.WithDecimalLiteral(t))
case string:
opts = append(opts, planner.WithStringLiteral(t))
case float64:
opts = append(opts, planner.WithRealLiteral(t))
case bool:
opts = append(opts, planner.WithBooleanLiteral(t))
}
c := planner.NewNodeConstant(GetOriginalText(constantCtx), opts...)
return planner.NewNodeExpressionAtom(text, planner.ExpressionAtomWithConstant(c))
}
func (v *AstBuilder) VisitFullColumnNameExpressionAtom(ctx *parsergen.FullColumnNameExpressionAtomContext) interface{} {
text := GetOriginalText(ctx)
fullColumnNameCtx := ctx.FullColumnName()
r := fullColumnNameCtx.Accept(v)
if err := GetError(r); err != nil {
return err
}
n := planner.NewNodeFullColumnName(GetOriginalText(fullColumnNameCtx), r.(string))
return planner.NewNodeExpressionAtom(text, planner.ExpressionAtomWithFullColumnName(n))
}
func (v *AstBuilder) VisitUnaryExpressionAtom(ctx *parsergen.UnaryExpressionAtomContext) interface{} {
text := GetOriginalText(ctx)
op := ctx.UnaryOperator().Accept(v).(planner.UnaryOperator)
expressionAtomCtx := ctx.ExpressionAtom()
r := expressionAtomCtx.Accept(v)
if err := GetError(r); err != nil {
return err
}
n := GetExpressionAtom(r)
expr := planner.NewNodeUnaryExpressionAtom(GetOriginalText(expressionAtomCtx), n, op)
return planner.NewNodeExpressionAtom(text, planner.ExpressionAtomWithUnaryExpr(expr))
}
func (v *AstBuilder) VisitNestedExpressionAtom(ctx *parsergen.NestedExpressionAtomContext) interface{} {
text := GetOriginalText(ctx)
expressionsCtx := ctx.AllExpression()
expressions := make([]*planner.NodeExpression, 0, len(expressionsCtx))
for _, expressionCtx := range expressionsCtx {
n, err := v.getExpression(expressionCtx)
if err != nil {
return err
}
expressions = append(expressions, n)
}
expr := planner.NewNodeNestedExpressionAtom(text, expressions)
return planner.NewNodeExpressionAtom(text, planner.ExpressionAtomWithNestedExpr(expr))
}
func (v *AstBuilder) VisitUnaryOperator(ctx *parsergen.UnaryOperatorContext) interface{} {
op := planner.UnaryOperatorUnknown
if ctx.EXCLAMATION_SYMBOL() != nil {
op = planner.UnaryOperatorExclamationSymbol
}
if ctx.BIT_NOT_OP() != nil {
op = planner.UnaryOperatorTilde
}
if ctx.PLUS() != nil {
op = planner.UnaryOperatorPositive
}
if ctx.MINUS() != nil {
op = planner.UnaryOperatorNegative
}
if ctx.NOT() != nil {
op = planner.UnaryOperatorNot
}
return op
}
func (v *AstBuilder) VisitComparisonOperator(ctx *parsergen.ComparisonOperatorContext) interface{} {
op := planner.ComparisonOperatorUnknown
if ctx.EXCLAMATION_SYMBOL() != nil {
op = planner.ComparisonOperatorNotEqual
}
if ctx.EQUAL_SYMBOL() != nil {
op |= planner.ComparisonOperatorEqual
}
if ctx.LESS_SYMBOL() != nil {
op |= planner.ComparisonOperatorLessThan
}
if ctx.GREATER_SYMBOL() != nil {
op |= planner.ComparisonOperatorGreaterThan
}
return op
}
func (v *AstBuilder) VisitLogicalOperator(ctx *parsergen.LogicalOperatorContext) interface{} {
op := planner.LogicalOperatorUnknown
if ctx.AND() != nil {
op = planner.LogicalOperatorAnd
}
if len(ctx.AllBIT_AND_OP()) != 0 {
op = planner.LogicalOperatorAnd
}
if ctx.OR() != nil {
op = planner.LogicalOperatorOr
}
if len(ctx.AllBIT_OR_OP()) != 0 {
op = planner.LogicalOperatorOr
}
return op
}
func (v *AstBuilder) Build(ctx antlr.ParserRuleContext) (planner.Node, error) {
r := ctx.Accept(v)
if err := GetError(r); err != nil {
return nil, err
}
if n := GetNode(r); n != nil {
return n, nil
}
return nil, fmt.Errorf("failed to parse ast tree: %s", GetOriginalText(ctx))
}
func NewAstBuilder(opts ...AstBuilderOption) *AstBuilder {
v := &AstBuilder{}
v.apply(opts...)
return v
}

View File

@ -0,0 +1,17 @@
package antlrparser
import (
"fmt"
"strconv"
"github.com/antlr/antlr4/runtime/Go/antlr/v4"
)
type ErrorListener struct {
*antlr.DefaultErrorListener
err error
}
func (l *ErrorListener) SyntaxError(recognizer antlr.Recognizer, offendingSymbol interface{}, line, column int, msg string, e antlr.RecognitionException) {
l.err = fmt.Errorf("line " + strconv.Itoa(line) + ":" + strconv.Itoa(column) + " " + msg)
}

View File

@ -0,0 +1,158 @@
package antlrparser
import (
"github.com/milvus-io/milvus/internal/mysqld/planner"
)
func GetError(obj interface{}) error {
err, ok := obj.(error)
if !ok {
// obj is not an error.
return nil
}
return err
}
func GetNode(obj interface{}) planner.Node {
n, ok := obj.(planner.Node)
if !ok {
return nil
}
return n
}
func GetSqlStatements(obj interface{}) *planner.NodeSqlStatements {
n, ok := obj.(*planner.NodeSqlStatements)
if !ok {
return nil
}
return n
}
func GetSqlStatement(obj interface{}) *planner.NodeSqlStatement {
n, ok := obj.(*planner.NodeSqlStatement)
if !ok {
return nil
}
return n
}
func GetDmlStatement(obj interface{}) *planner.NodeDmlStatement {
n, ok := obj.(*planner.NodeDmlStatement)
if !ok {
return nil
}
return n
}
func GetSelectStatement(obj interface{}) *planner.NodeSelectStatement {
n, ok := obj.(*planner.NodeSelectStatement)
if !ok {
return nil
}
return n
}
func GetQuerySpecification(obj interface{}) *planner.NodeQuerySpecification {
n, ok := obj.(*planner.NodeQuerySpecification)
if !ok {
return nil
}
return n
}
func GetLockClause(obj interface{}) *planner.NodeLockClause {
n, ok := obj.(*planner.NodeLockClause)
if !ok {
return nil
}
return n
}
func GetSelectSpec(obj interface{}) *planner.NodeSelectSpec {
n, ok := obj.(*planner.NodeSelectSpec)
if !ok {
return nil
}
return n
}
func GetSelectElement(obj interface{}) *planner.NodeSelectElement {
n, ok := obj.(*planner.NodeSelectElement)
if !ok {
return nil
}
return n
}
func GetFromClause(obj interface{}) *planner.NodeFromClause {
n, ok := obj.(*planner.NodeFromClause)
if !ok {
return nil
}
return n
}
func GetLimitClause(obj interface{}) *planner.NodeLimitClause {
n, ok := obj.(*planner.NodeLimitClause)
if !ok {
return nil
}
return n
}
func GetAggregateWindowedFunction(obj interface{}) *planner.NodeAggregateWindowedFunction {
n, ok := obj.(*planner.NodeAggregateWindowedFunction)
if !ok {
return nil
}
return n
}
func GetCount(obj interface{}) *planner.NodeCount {
n, ok := obj.(*planner.NodeCount)
if !ok {
return nil
}
return n
}
func GetTableSource(obj interface{}) *planner.NodeTableSource {
n, ok := obj.(*planner.NodeTableSource)
if !ok {
return nil
}
return n
}
func GetExpression(obj interface{}) *planner.NodeExpression {
n, ok := obj.(*planner.NodeExpression)
if !ok {
return nil
}
return n
}
func GetPredicate(obj interface{}) *planner.NodePredicate {
n, ok := obj.(*planner.NodePredicate)
if !ok {
return nil
}
return n
}
func GetExpressionAtom(obj interface{}) *planner.NodeExpressionAtom {
n, ok := obj.(*planner.NodeExpressionAtom)
if !ok {
return nil
}
return n
}
func GetExpressions(obj interface{}) *planner.NodeExpressions {
n, ok := obj.(*planner.NodeExpressions)
if !ok {
return nil
}
return n
}

View File

@ -0,0 +1,42 @@
package antlrparser
import (
"github.com/antlr/antlr4/runtime/Go/antlr/v4"
"github.com/milvus-io/milvus/internal/mysqld/parser"
"github.com/milvus-io/milvus/internal/mysqld/planner"
)
type antlrParser struct{}
func (p antlrParser) Parse(sql string, opts ...parser.Option) (*planner.LogicalPlan, []error, error) {
el := &ErrorListener{}
inputStream := antlr.NewInputStream(sql)
lexer := getLexer(inputStream, el)
defer putLexer(lexer)
if el.err != nil {
return nil, nil, el.err
}
parserFromPool := getParser(lexer, el)
defer putParser(parserFromPool)
if el.err != nil {
return nil, nil, el.err
}
ast := parserFromPool.Root()
n, err := NewAstBuilder().Build(ast)
if err != nil {
return nil, nil, err
}
return &planner.LogicalPlan{
Node: n,
}, nil, nil
}
func NewAntlrParser() parser.Parser {
return &antlrParser{}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,3 @@
package parser
//go:generate ./generate.sh

View File

@ -0,0 +1,4 @@
#!/bin/sh
alias antlr4='java -Xmx500M -cp "../../../../../tools/antlr/antlr-4.11.1-complete.jar:$CLASSPATH" org.antlr.v4.Tool'
antlr4 -Dlanguage=Go -no-listener -visitor -package parser *.g4

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,192 @@
// Code generated from java-escape by ANTLR 4.11.1. DO NOT EDIT.
package parser // MySqlParser
import "github.com/antlr/antlr4/runtime/Go/antlr/v4"
type BaseMySqlParserVisitor struct {
*antlr.BaseParseTreeVisitor
}
func (v *BaseMySqlParserVisitor) VisitRoot(ctx *RootContext) interface{} {
return v.VisitChildren(ctx)
}
func (v *BaseMySqlParserVisitor) VisitSqlStatements(ctx *SqlStatementsContext) interface{} {
return v.VisitChildren(ctx)
}
func (v *BaseMySqlParserVisitor) VisitSqlStatement(ctx *SqlStatementContext) interface{} {
return v.VisitChildren(ctx)
}
func (v *BaseMySqlParserVisitor) VisitEmptyStatement_(ctx *EmptyStatement_Context) interface{} {
return v.VisitChildren(ctx)
}
func (v *BaseMySqlParserVisitor) VisitDmlStatement(ctx *DmlStatementContext) interface{} {
return v.VisitChildren(ctx)
}
func (v *BaseMySqlParserVisitor) VisitSimpleSelect(ctx *SimpleSelectContext) interface{} {
return v.VisitChildren(ctx)
}
func (v *BaseMySqlParserVisitor) VisitLockClause(ctx *LockClauseContext) interface{} {
return v.VisitChildren(ctx)
}
func (v *BaseMySqlParserVisitor) VisitTableSources(ctx *TableSourcesContext) interface{} {
return v.VisitChildren(ctx)
}
func (v *BaseMySqlParserVisitor) VisitTableSourceBase(ctx *TableSourceBaseContext) interface{} {
return v.VisitChildren(ctx)
}
func (v *BaseMySqlParserVisitor) VisitQuerySpecification(ctx *QuerySpecificationContext) interface{} {
return v.VisitChildren(ctx)
}
func (v *BaseMySqlParserVisitor) VisitSelectSpec(ctx *SelectSpecContext) interface{} {
return v.VisitChildren(ctx)
}
func (v *BaseMySqlParserVisitor) VisitSelectElements(ctx *SelectElementsContext) interface{} {
return v.VisitChildren(ctx)
}
func (v *BaseMySqlParserVisitor) VisitSelectColumnElement(ctx *SelectColumnElementContext) interface{} {
return v.VisitChildren(ctx)
}
func (v *BaseMySqlParserVisitor) VisitSelectFunctionElement(ctx *SelectFunctionElementContext) interface{} {
return v.VisitChildren(ctx)
}
func (v *BaseMySqlParserVisitor) VisitFromClause(ctx *FromClauseContext) interface{} {
return v.VisitChildren(ctx)
}
func (v *BaseMySqlParserVisitor) VisitLimitClause(ctx *LimitClauseContext) interface{} {
return v.VisitChildren(ctx)
}
func (v *BaseMySqlParserVisitor) VisitLimitClauseAtom(ctx *LimitClauseAtomContext) interface{} {
return v.VisitChildren(ctx)
}
func (v *BaseMySqlParserVisitor) VisitFullId(ctx *FullIdContext) interface{} {
return v.VisitChildren(ctx)
}
func (v *BaseMySqlParserVisitor) VisitTableName(ctx *TableNameContext) interface{} {
return v.VisitChildren(ctx)
}
func (v *BaseMySqlParserVisitor) VisitFullColumnName(ctx *FullColumnNameContext) interface{} {
return v.VisitChildren(ctx)
}
func (v *BaseMySqlParserVisitor) VisitCollationName(ctx *CollationNameContext) interface{} {
return v.VisitChildren(ctx)
}
func (v *BaseMySqlParserVisitor) VisitUid(ctx *UidContext) interface{} {
return v.VisitChildren(ctx)
}
func (v *BaseMySqlParserVisitor) VisitSimpleId(ctx *SimpleIdContext) interface{} {
return v.VisitChildren(ctx)
}
func (v *BaseMySqlParserVisitor) VisitDottedId(ctx *DottedIdContext) interface{} {
return v.VisitChildren(ctx)
}
func (v *BaseMySqlParserVisitor) VisitDecimalLiteral(ctx *DecimalLiteralContext) interface{} {
return v.VisitChildren(ctx)
}
func (v *BaseMySqlParserVisitor) VisitStringLiteral(ctx *StringLiteralContext) interface{} {
return v.VisitChildren(ctx)
}
func (v *BaseMySqlParserVisitor) VisitBooleanLiteral(ctx *BooleanLiteralContext) interface{} {
return v.VisitChildren(ctx)
}
func (v *BaseMySqlParserVisitor) VisitHexadecimalLiteral(ctx *HexadecimalLiteralContext) interface{} {
return v.VisitChildren(ctx)
}
func (v *BaseMySqlParserVisitor) VisitConstant(ctx *ConstantContext) interface{} {
return v.VisitChildren(ctx)
}
func (v *BaseMySqlParserVisitor) VisitExpressions(ctx *ExpressionsContext) interface{} {
return v.VisitChildren(ctx)
}
func (v *BaseMySqlParserVisitor) VisitAggregateFunctionCall(ctx *AggregateFunctionCallContext) interface{} {
return v.VisitChildren(ctx)
}
func (v *BaseMySqlParserVisitor) VisitAggregateWindowedFunction(ctx *AggregateWindowedFunctionContext) interface{} {
return v.VisitChildren(ctx)
}
func (v *BaseMySqlParserVisitor) VisitIsExpression(ctx *IsExpressionContext) interface{} {
return v.VisitChildren(ctx)
}
func (v *BaseMySqlParserVisitor) VisitNotExpression(ctx *NotExpressionContext) interface{} {
return v.VisitChildren(ctx)
}
func (v *BaseMySqlParserVisitor) VisitLogicalExpression(ctx *LogicalExpressionContext) interface{} {
return v.VisitChildren(ctx)
}
func (v *BaseMySqlParserVisitor) VisitPredicateExpression(ctx *PredicateExpressionContext) interface{} {
return v.VisitChildren(ctx)
}
func (v *BaseMySqlParserVisitor) VisitExpressionAtomPredicate(ctx *ExpressionAtomPredicateContext) interface{} {
return v.VisitChildren(ctx)
}
func (v *BaseMySqlParserVisitor) VisitBinaryComparisonPredicate(ctx *BinaryComparisonPredicateContext) interface{} {
return v.VisitChildren(ctx)
}
func (v *BaseMySqlParserVisitor) VisitInPredicate(ctx *InPredicateContext) interface{} {
return v.VisitChildren(ctx)
}
func (v *BaseMySqlParserVisitor) VisitConstantExpressionAtom(ctx *ConstantExpressionAtomContext) interface{} {
return v.VisitChildren(ctx)
}
func (v *BaseMySqlParserVisitor) VisitFullColumnNameExpressionAtom(ctx *FullColumnNameExpressionAtomContext) interface{} {
return v.VisitChildren(ctx)
}
func (v *BaseMySqlParserVisitor) VisitUnaryExpressionAtom(ctx *UnaryExpressionAtomContext) interface{} {
return v.VisitChildren(ctx)
}
func (v *BaseMySqlParserVisitor) VisitNestedExpressionAtom(ctx *NestedExpressionAtomContext) interface{} {
return v.VisitChildren(ctx)
}
func (v *BaseMySqlParserVisitor) VisitUnaryOperator(ctx *UnaryOperatorContext) interface{} {
return v.VisitChildren(ctx)
}
func (v *BaseMySqlParserVisitor) VisitComparisonOperator(ctx *ComparisonOperatorContext) interface{} {
return v.VisitChildren(ctx)
}
func (v *BaseMySqlParserVisitor) VisitLogicalOperator(ctx *LogicalOperatorContext) interface{} {
return v.VisitChildren(ctx)
}

View File

@ -0,0 +1,147 @@
// Code generated from java-escape by ANTLR 4.11.1. DO NOT EDIT.
package parser // MySqlParser
import "github.com/antlr/antlr4/runtime/Go/antlr/v4"
// A complete Visitor for a parse tree produced by MySqlParser.
type MySqlParserVisitor interface {
antlr.ParseTreeVisitor
// Visit a parse tree produced by MySqlParser#root.
VisitRoot(ctx *RootContext) interface{}
// Visit a parse tree produced by MySqlParser#sqlStatements.
VisitSqlStatements(ctx *SqlStatementsContext) interface{}
// Visit a parse tree produced by MySqlParser#sqlStatement.
VisitSqlStatement(ctx *SqlStatementContext) interface{}
// Visit a parse tree produced by MySqlParser#emptyStatement_.
VisitEmptyStatement_(ctx *EmptyStatement_Context) interface{}
// Visit a parse tree produced by MySqlParser#dmlStatement.
VisitDmlStatement(ctx *DmlStatementContext) interface{}
// Visit a parse tree produced by MySqlParser#simpleSelect.
VisitSimpleSelect(ctx *SimpleSelectContext) interface{}
// Visit a parse tree produced by MySqlParser#lockClause.
VisitLockClause(ctx *LockClauseContext) interface{}
// Visit a parse tree produced by MySqlParser#tableSources.
VisitTableSources(ctx *TableSourcesContext) interface{}
// Visit a parse tree produced by MySqlParser#tableSourceBase.
VisitTableSourceBase(ctx *TableSourceBaseContext) interface{}
// Visit a parse tree produced by MySqlParser#querySpecification.
VisitQuerySpecification(ctx *QuerySpecificationContext) interface{}
// Visit a parse tree produced by MySqlParser#selectSpec.
VisitSelectSpec(ctx *SelectSpecContext) interface{}
// Visit a parse tree produced by MySqlParser#selectElements.
VisitSelectElements(ctx *SelectElementsContext) interface{}
// Visit a parse tree produced by MySqlParser#selectColumnElement.
VisitSelectColumnElement(ctx *SelectColumnElementContext) interface{}
// Visit a parse tree produced by MySqlParser#selectFunctionElement.
VisitSelectFunctionElement(ctx *SelectFunctionElementContext) interface{}
// Visit a parse tree produced by MySqlParser#fromClause.
VisitFromClause(ctx *FromClauseContext) interface{}
// Visit a parse tree produced by MySqlParser#limitClause.
VisitLimitClause(ctx *LimitClauseContext) interface{}
// Visit a parse tree produced by MySqlParser#limitClauseAtom.
VisitLimitClauseAtom(ctx *LimitClauseAtomContext) interface{}
// Visit a parse tree produced by MySqlParser#fullId.
VisitFullId(ctx *FullIdContext) interface{}
// Visit a parse tree produced by MySqlParser#tableName.
VisitTableName(ctx *TableNameContext) interface{}
// Visit a parse tree produced by MySqlParser#fullColumnName.
VisitFullColumnName(ctx *FullColumnNameContext) interface{}
// Visit a parse tree produced by MySqlParser#collationName.
VisitCollationName(ctx *CollationNameContext) interface{}
// Visit a parse tree produced by MySqlParser#uid.
VisitUid(ctx *UidContext) interface{}
// Visit a parse tree produced by MySqlParser#simpleId.
VisitSimpleId(ctx *SimpleIdContext) interface{}
// Visit a parse tree produced by MySqlParser#dottedId.
VisitDottedId(ctx *DottedIdContext) interface{}
// Visit a parse tree produced by MySqlParser#decimalLiteral.
VisitDecimalLiteral(ctx *DecimalLiteralContext) interface{}
// Visit a parse tree produced by MySqlParser#stringLiteral.
VisitStringLiteral(ctx *StringLiteralContext) interface{}
// Visit a parse tree produced by MySqlParser#booleanLiteral.
VisitBooleanLiteral(ctx *BooleanLiteralContext) interface{}
// Visit a parse tree produced by MySqlParser#hexadecimalLiteral.
VisitHexadecimalLiteral(ctx *HexadecimalLiteralContext) interface{}
// Visit a parse tree produced by MySqlParser#constant.
VisitConstant(ctx *ConstantContext) interface{}
// Visit a parse tree produced by MySqlParser#expressions.
VisitExpressions(ctx *ExpressionsContext) interface{}
// Visit a parse tree produced by MySqlParser#aggregateFunctionCall.
VisitAggregateFunctionCall(ctx *AggregateFunctionCallContext) interface{}
// Visit a parse tree produced by MySqlParser#aggregateWindowedFunction.
VisitAggregateWindowedFunction(ctx *AggregateWindowedFunctionContext) interface{}
// Visit a parse tree produced by MySqlParser#isExpression.
VisitIsExpression(ctx *IsExpressionContext) interface{}
// Visit a parse tree produced by MySqlParser#notExpression.
VisitNotExpression(ctx *NotExpressionContext) interface{}
// Visit a parse tree produced by MySqlParser#logicalExpression.
VisitLogicalExpression(ctx *LogicalExpressionContext) interface{}
// Visit a parse tree produced by MySqlParser#predicateExpression.
VisitPredicateExpression(ctx *PredicateExpressionContext) interface{}
// Visit a parse tree produced by MySqlParser#expressionAtomPredicate.
VisitExpressionAtomPredicate(ctx *ExpressionAtomPredicateContext) interface{}
// Visit a parse tree produced by MySqlParser#binaryComparisonPredicate.
VisitBinaryComparisonPredicate(ctx *BinaryComparisonPredicateContext) interface{}
// Visit a parse tree produced by MySqlParser#inPredicate.
VisitInPredicate(ctx *InPredicateContext) interface{}
// Visit a parse tree produced by MySqlParser#constantExpressionAtom.
VisitConstantExpressionAtom(ctx *ConstantExpressionAtomContext) interface{}
// Visit a parse tree produced by MySqlParser#fullColumnNameExpressionAtom.
VisitFullColumnNameExpressionAtom(ctx *FullColumnNameExpressionAtomContext) interface{}
// Visit a parse tree produced by MySqlParser#unaryExpressionAtom.
VisitUnaryExpressionAtom(ctx *UnaryExpressionAtomContext) interface{}
// Visit a parse tree produced by MySqlParser#nestedExpressionAtom.
VisitNestedExpressionAtom(ctx *NestedExpressionAtomContext) interface{}
// Visit a parse tree produced by MySqlParser#unaryOperator.
VisitUnaryOperator(ctx *UnaryOperatorContext) interface{}
// Visit a parse tree produced by MySqlParser#comparisonOperator.
VisitComparisonOperator(ctx *ComparisonOperatorContext) interface{}
// Visit a parse tree produced by MySqlParser#logicalOperator.
VisitLogicalOperator(ctx *LogicalOperatorContext) interface{}
}

View File

@ -0,0 +1,50 @@
package antlrparser
import (
"fmt"
"testing"
"github.com/stretchr/testify/assert"
"github.com/milvus-io/milvus/internal/mysqld/planner"
)
func Test_antlrParser_Parse(t *testing.T) {
restore := func(t *testing.T, n planner.Node) {
text := planner.NewExprTextRestorer().RestoreExprText(n)
fmt.Println(text)
}
debug := func(t *testing.T, sql string) {
plan, warns, err := NewAntlrParser().Parse(sql)
assert.NoError(t, err)
assert.Nil(t, warns)
fmt.Println(sql)
planner.NewTreeUtils().PrettyPrintHrn(GetSqlStatements(plan.Node))
fmt.Println()
statements := GetSqlStatements(plan.Node)
expr := statements.Statements[0].
DmlStatement.Unwrap().
SelectStatement.Unwrap().
SimpleSelect.Unwrap().
Query.Unwrap().
From.Unwrap().
Where
if expr.IsSome() {
restore(t, expr.Unwrap())
}
}
sqls := []string{
"select a as f1, b as f2 from t", // query without predicate
"select a as f1, b as f2 from t where a > 5 and b < 2", // query with predicate
"select count(*) as cnt from t", // count without predicate
"select count(*) as cnt from t where a > 5 and b < 2", // count with predicate
"select a as f1, b as f2 from t where a > 5 and b < 2 limit 9, 4", // query with predicate and limit
"select a as f1, b as f2 from t where a > 5 and b < 2 limit 4 offset 9", // query with predicate and limit
}
for _, sql := range sqls {
debug(t, sql)
}
}

View File

@ -0,0 +1,57 @@
package antlrparser
import (
"sync"
"github.com/antlr/antlr4/runtime/Go/antlr/v4"
parsergen "github.com/milvus-io/milvus/internal/mysqld/parser/antlrparser/parser"
)
var (
lexerPool = sync.Pool{
New: func() interface{} {
return parsergen.NewMySqlLexer(nil)
},
}
parserPool = sync.Pool{
New: func() interface{} {
return parsergen.NewMySqlParser(nil)
},
}
)
func getLexer(stream *antlr.InputStream, listeners ...antlr.ErrorListener) *parsergen.MySqlLexer {
lexer, ok := lexerPool.Get().(*parsergen.MySqlLexer)
if !ok {
lexer = parsergen.NewMySqlLexer(nil)
}
for _, listener := range listeners {
lexer.AddErrorListener(listener)
}
lexer.SetInputStream(stream)
return lexer
}
func getParser(lexer *parsergen.MySqlLexer, listeners ...antlr.ErrorListener) *parsergen.MySqlParser {
tokenStream := antlr.NewCommonTokenStream(lexer, antlr.TokenDefaultChannel)
parser, ok := parserPool.Get().(*parsergen.MySqlParser)
if !ok {
parser = parsergen.NewMySqlParser(nil)
}
for _, listener := range listeners {
parser.AddErrorListener(listener)
}
parser.BuildParseTrees = true
parser.SetInputStream(tokenStream)
return parser
}
func putLexer(lexer *parsergen.MySqlLexer) {
lexer.SetInputStream(nil)
lexerPool.Put(lexer)
}
func putParser(parser *parsergen.MySqlParser) {
parser.SetInputStream(nil)
parserPool.Put(parser)
}

View File

@ -0,0 +1,20 @@
package antlrparser
import (
"strings"
"github.com/antlr/antlr4/runtime/Go/antlr/v4"
)
func CaseInsensitiveEqual(s1, s2 string) bool {
return strings.ToLower(s1) == strings.ToLower(s2)
}
// GetOriginalText don't work.
func GetOriginalText(ctx antlr.ParserRuleContext) string {
if true {
return ctx.GetText()
}
interval := ctx.GetSourceInterval()
return ctx.GetStart().GetInputStream().GetTextFromInterval(interval)
}

View File

@ -0,0 +1,15 @@
package parser
type Config struct{}
type Option = func(c *Config)
func (c *Config) Apply(opts ...Option) {
for _, opt := range opts {
opt(c)
}
}
func defaultParserConfig() Config {
return Config{}
}

View File

@ -0,0 +1,9 @@
package parser
import (
"github.com/milvus-io/milvus/internal/mysqld/planner"
)
type Parser interface {
Parse(sql string, opts ...Option) (*planner.LogicalPlan, []error, error)
}

View File

@ -0,0 +1,47 @@
package planner
import (
"github.com/moznion/go-optional"
)
type NodeAggregateWindowedFunction struct {
baseNode
AggCount optional.Option[*NodeCount]
}
func (n *NodeAggregateWindowedFunction) String() string {
return "NodeAggregateWindowedFunction"
}
func (n *NodeAggregateWindowedFunction) GetChildren() []Node {
if n.AggCount.IsSome() {
return []Node{n.AggCount.Unwrap()}
}
return nil
}
func (n *NodeAggregateWindowedFunction) Accept(v Visitor) interface{} {
return v.VisitAggregateWindowedFunction(n)
}
type NodeAggregateWindowedFunctionOption func(*NodeAggregateWindowedFunction)
func (n *NodeAggregateWindowedFunction) apply(opts ...NodeAggregateWindowedFunctionOption) {
for _, opt := range opts {
opt(n)
}
}
func WithAggCount(c *NodeCount) NodeAggregateWindowedFunctionOption {
return func(n *NodeAggregateWindowedFunction) {
n.AggCount = optional.Some(c)
}
}
func NewNodeAggregateWindowedFunction(text string, opts ...NodeAggregateWindowedFunctionOption) *NodeAggregateWindowedFunction {
n := &NodeAggregateWindowedFunction{
baseNode: newBaseNode(text),
}
n.apply(opts...)
return n
}

View File

@ -0,0 +1,31 @@
package planner
import "fmt"
type NodeBinaryComparisonPredicate struct {
baseNode
Left *NodePredicate
Right *NodePredicate
Op ComparisonOperator
}
func (n *NodeBinaryComparisonPredicate) String() string {
return fmt.Sprintf("NodeBinaryComparisonPredicate, Op: %v", n.Op)
}
func (n *NodeBinaryComparisonPredicate) GetChildren() []Node {
return []Node{n.Left, n.Right}
}
func (n *NodeBinaryComparisonPredicate) Accept(v Visitor) interface{} {
return v.VisitBinaryComparisonPredicate(n)
}
func NewNodeBinaryComparisonPredicate(text string, left, right *NodePredicate, op ComparisonOperator) *NodeBinaryComparisonPredicate {
return &NodeBinaryComparisonPredicate{
baseNode: newBaseNode(text),
Left: left,
Right: right,
Op: op,
}
}

View File

@ -0,0 +1,63 @@
package planner
import "github.com/moznion/go-optional"
type NodeConstant struct {
baseNode
StringLiteral optional.Option[string]
DecimalLiteral optional.Option[int64]
BooleanLiteral optional.Option[bool]
RealLiteral optional.Option[float64]
}
func (n *NodeConstant) String() string {
return "NodeConstant: " + n.GetText()
}
func (n *NodeConstant) GetChildren() []Node {
return nil
}
func (n *NodeConstant) Accept(v Visitor) interface{} {
return v.VisitConstant(n)
}
type NodeConstantOption func(*NodeConstant)
func (n *NodeConstant) apply(opts ...NodeConstantOption) {
for _, opt := range opts {
opt(n)
}
}
func WithStringLiteral(s string) NodeConstantOption {
return func(n *NodeConstant) {
n.StringLiteral = optional.Some(s)
}
}
func WithDecimalLiteral(s int64) NodeConstantOption {
return func(n *NodeConstant) {
n.DecimalLiteral = optional.Some(s)
}
}
func WithBooleanLiteral(s bool) NodeConstantOption {
return func(n *NodeConstant) {
n.BooleanLiteral = optional.Some(s)
}
}
func WithRealLiteral(s float64) NodeConstantOption {
return func(n *NodeConstant) {
n.RealLiteral = optional.Some(s)
}
}
func NewNodeConstant(text string, opts ...NodeConstantOption) *NodeConstant {
n := &NodeConstant{
baseNode: newBaseNode(text),
}
n.apply(opts...)
return n
}

View File

@ -0,0 +1,23 @@
package planner
type NodeCount struct {
baseNode
}
func (n *NodeCount) String() string {
return "NodeCount"
}
func (n *NodeCount) GetChildren() []Node {
return nil
}
func (n *NodeCount) Accept(v Visitor) interface{} {
return v.VisitCount(n)
}
func NewNodeCount(text string) *NodeCount {
return &NodeCount{
baseNode: newBaseNode(text),
}
}

View File

@ -0,0 +1,45 @@
package planner
import "github.com/moznion/go-optional"
type NodeDmlStatement struct {
baseNode
SelectStatement optional.Option[*NodeSelectStatement]
}
func (n *NodeDmlStatement) String() string {
return "NodeDmlStatement"
}
func (n *NodeDmlStatement) GetChildren() []Node {
if n.SelectStatement.IsSome() {
return []Node{n.SelectStatement.Unwrap()}
}
return nil
}
func (n *NodeDmlStatement) Accept(v Visitor) interface{} {
return v.VisitDmlStatement(n)
}
type NodeDmlStatementOption func(*NodeDmlStatement)
func (n *NodeDmlStatement) apply(opts ...NodeDmlStatementOption) {
for _, opt := range opts {
opt(n)
}
}
func WithSelectStatement(s *NodeSelectStatement) NodeDmlStatementOption {
return func(n *NodeDmlStatement) {
n.SelectStatement = optional.Some(s)
}
}
func NewNodeDmlStatement(text string, opts ...NodeDmlStatementOption) *NodeDmlStatement {
n := &NodeDmlStatement{
baseNode: newBaseNode(text),
}
n.apply(opts...)
return n
}

View File

@ -0,0 +1,75 @@
package planner
import "github.com/moznion/go-optional"
type NodeExpression struct {
baseNode
NotExpr optional.Option[*NodeNotExpression]
LogicalExpr optional.Option[*NodeLogicalExpression]
IsExpr optional.Option[*NodeIsExpression]
Predicate optional.Option[*NodePredicate]
}
func (n *NodeExpression) String() string {
return "NodeExpression"
}
func (n *NodeExpression) GetChildren() []Node {
if n.NotExpr.IsSome() {
return []Node{n.NotExpr.Unwrap()}
}
if n.LogicalExpr.IsSome() {
return []Node{n.LogicalExpr.Unwrap()}
}
if n.IsExpr.IsSome() {
return []Node{n.IsExpr.Unwrap()}
}
if n.Predicate.IsSome() {
return []Node{n.Predicate.Unwrap()}
}
return nil
}
func (n *NodeExpression) Accept(v Visitor) interface{} {
return v.VisitExpression(n)
}
type NodeExpressionOption func(*NodeExpression)
func (n *NodeExpression) apply(opts ...NodeExpressionOption) {
for _, opt := range opts {
opt(n)
}
}
func WithNotExpr(expr *NodeNotExpression) NodeExpressionOption {
return func(n *NodeExpression) {
n.NotExpr = optional.Some(expr)
}
}
func WithLogicalExpr(expr *NodeLogicalExpression) NodeExpressionOption {
return func(n *NodeExpression) {
n.LogicalExpr = optional.Some(expr)
}
}
func WithIsExpr(expr *NodeIsExpression) NodeExpressionOption {
return func(n *NodeExpression) {
n.IsExpr = optional.Some(expr)
}
}
func WithPredicate(predicate *NodePredicate) NodeExpressionOption {
return func(n *NodeExpression) {
n.Predicate = optional.Some(predicate)
}
}
func NewNodeExpression(text string, opts ...NodeExpressionOption) *NodeExpression {
n := &NodeExpression{
baseNode: newBaseNode(text),
}
n.apply(opts...)
return n
}

View File

@ -0,0 +1,75 @@
package planner
import "github.com/moznion/go-optional"
type NodeExpressionAtom struct {
baseNode
Constant optional.Option[*NodeConstant]
FullColumnName optional.Option[*NodeFullColumnName]
UnaryExpr optional.Option[*NodeUnaryExpressionAtom]
NestedExpr optional.Option[*NodeNestedExpressionAtom]
}
func (n *NodeExpressionAtom) String() string {
return "NodeExpression"
}
func (n *NodeExpressionAtom) GetChildren() []Node {
if n.Constant.IsSome() {
return []Node{n.Constant.Unwrap()}
}
if n.FullColumnName.IsSome() {
return []Node{n.FullColumnName.Unwrap()}
}
if n.UnaryExpr.IsSome() {
return []Node{n.UnaryExpr.Unwrap()}
}
if n.NestedExpr.IsSome() {
return []Node{n.NestedExpr.Unwrap()}
}
return nil
}
func (n *NodeExpressionAtom) Accept(v Visitor) interface{} {
return v.VisitExpressionAtom(n)
}
type NodeExpressionAtomOption func(*NodeExpressionAtom)
func (n *NodeExpressionAtom) apply(opts ...NodeExpressionAtomOption) {
for _, opt := range opts {
opt(n)
}
}
func ExpressionAtomWithConstant(c *NodeConstant) NodeExpressionAtomOption {
return func(n *NodeExpressionAtom) {
n.Constant = optional.Some(c)
}
}
func ExpressionAtomWithFullColumnName(c *NodeFullColumnName) NodeExpressionAtomOption {
return func(n *NodeExpressionAtom) {
n.FullColumnName = optional.Some(c)
}
}
func ExpressionAtomWithUnaryExpr(c *NodeUnaryExpressionAtom) NodeExpressionAtomOption {
return func(n *NodeExpressionAtom) {
n.UnaryExpr = optional.Some(c)
}
}
func ExpressionAtomWithNestedExpr(c *NodeNestedExpressionAtom) NodeExpressionAtomOption {
return func(n *NodeExpressionAtom) {
n.NestedExpr = optional.Some(c)
}
}
func NewNodeExpressionAtom(text string, opts ...NodeExpressionAtomOption) *NodeExpressionAtom {
n := &NodeExpressionAtom{
baseNode: newBaseNode(text),
}
n.apply(opts...)
return n
}

View File

@ -0,0 +1,44 @@
package planner
import "github.com/moznion/go-optional"
type NodeExpressionAtomPredicate struct {
baseNode
Assignment optional.Option[*NodeLocalID]
ExpressionAtom *NodeExpressionAtom
}
func (n *NodeExpressionAtomPredicate) String() string {
return "NodeExpressionAtomPredicate"
}
func (n *NodeExpressionAtomPredicate) GetChildren() []Node {
return []Node{n.ExpressionAtom}
}
func (n *NodeExpressionAtomPredicate) Accept(v Visitor) interface{} {
return v.VisitExpressionAtomPredicate(n)
}
type NodeExpressionAtomPredicateOption func(*NodeExpressionAtomPredicate)
func (n *NodeExpressionAtomPredicate) apply(opts ...NodeExpressionAtomPredicateOption) {
for _, opt := range opts {
opt(n)
}
}
func WithAssignment(assign *NodeLocalID) NodeExpressionAtomPredicateOption {
return func(n *NodeExpressionAtomPredicate) {
n.Assignment = optional.Some(assign)
}
}
func NewNodeExpressionAtomPredicate(text string, exprAtom *NodeExpressionAtom, opts ...NodeExpressionAtomPredicateOption) *NodeExpressionAtomPredicate {
n := &NodeExpressionAtomPredicate{
baseNode: newBaseNode(text),
ExpressionAtom: exprAtom,
}
n.apply(opts...)
return n
}

View File

@ -0,0 +1,134 @@
package planner
import (
"fmt"
"strconv"
)
// TODO: remove this after execution engine is ready.
type exprTextRestorer struct {
Visitor
}
func (v *exprTextRestorer) VisitFullColumnName(n *NodeFullColumnName) interface{} {
return n.Name
}
func (v *exprTextRestorer) VisitExpression(n *NodeExpression) interface{} {
if n.NotExpr.IsSome() {
return n.NotExpr.Unwrap().Accept(v)
}
if n.LogicalExpr.IsSome() {
return n.LogicalExpr.Unwrap().Accept(v)
}
if n.IsExpr.IsSome() {
return n.IsExpr.Unwrap().Accept(v)
}
if n.Predicate.IsSome() {
return n.Predicate.Unwrap().Accept(v)
}
return ""
}
func (v *exprTextRestorer) VisitExpressions(n *NodeExpressions) interface{} {
l := len(n.Expressions)
if l == 0 {
return ""
}
s := n.Expressions[0].Accept(v).(string)
for i := 1; i < l; i++ {
s += fmt.Sprintf(", %s", n.Expressions[i].Accept(v))
}
return s
}
func (v *exprTextRestorer) VisitNotExpression(n *NodeNotExpression) interface{} {
r := n.Expression.Accept(v)
return fmt.Sprintf("not (%s)", r)
}
func (v *exprTextRestorer) VisitLogicalExpression(n *NodeLogicalExpression) interface{} {
l := n.Left.Accept(v)
r := n.Right.Accept(v)
return fmt.Sprintf("(%s) %s (%s)", l, n.Op, r)
}
func (v *exprTextRestorer) VisitIsExpression(n *NodeIsExpression) interface{} {
r := n.Predicate.Accept(v)
return fmt.Sprintf("%s (%s)", n.Op, r)
}
func (v *exprTextRestorer) VisitPredicate(n *NodePredicate) interface{} {
if n.InPredicate.IsSome() {
return n.InPredicate.Unwrap().Accept(v)
}
if n.BinaryComparisonPredicate.IsSome() {
return n.BinaryComparisonPredicate.Unwrap().Accept(v)
}
if n.ExpressionAtomPredicate.IsSome() {
return n.ExpressionAtomPredicate.Unwrap().Accept(v)
}
return ""
}
func (v *exprTextRestorer) VisitInPredicate(n *NodeInPredicate) interface{} {
// TODO: consider () instead of []
predicate := n.Predicate.Accept(v)
exprs := n.Expressions.Accept(v)
return fmt.Sprintf("(%s) %s [%s]", predicate, n.Op, exprs)
}
func (v *exprTextRestorer) VisitBinaryComparisonPredicate(n *NodeBinaryComparisonPredicate) interface{} {
l := n.Left.Accept(v)
r := n.Right.Accept(v)
return fmt.Sprintf("(%s) %s (%s)", l, n.Op, r)
}
func (v *exprTextRestorer) VisitExpressionAtomPredicate(n *NodeExpressionAtomPredicate) interface{} {
return n.ExpressionAtom.Accept(v)
}
func (v *exprTextRestorer) VisitExpressionAtom(n *NodeExpressionAtom) interface{} {
if n.Constant.IsSome() {
return n.Constant.Unwrap().Accept(v)
}
if n.FullColumnName.IsSome() {
return n.FullColumnName.Unwrap().Accept(v)
}
if n.UnaryExpr.IsSome() {
return n.UnaryExpr.Unwrap().Accept(v)
}
if n.NestedExpr.IsSome() {
return n.NestedExpr.Unwrap().Accept(v)
}
return ""
}
func (v *exprTextRestorer) VisitUnaryExpressionAtom(n *NodeUnaryExpressionAtom) interface{} {
expr := n.Expr.Accept(v)
return fmt.Sprintf("%s (%s)", n.Op, expr)
}
func (v *exprTextRestorer) VisitConstant(n *NodeConstant) interface{} {
if n.StringLiteral.IsSome() {
return n.StringLiteral.Unwrap()
}
if n.DecimalLiteral.IsSome() {
return strconv.Itoa(int(n.DecimalLiteral.Unwrap()))
}
if n.BooleanLiteral.IsSome() {
return strconv.FormatBool(n.BooleanLiteral.Unwrap())
}
if n.RealLiteral.IsSome() {
return strconv.FormatFloat(n.RealLiteral.Unwrap(), 'g', 10, 14)
}
return ""
}
func (v *exprTextRestorer) RestoreExprText(n Node) string {
return n.Accept(v).(string)
}
func NewExprTextRestorer() *exprTextRestorer {
return &exprTextRestorer{}
}

View File

@ -0,0 +1,29 @@
package planner
type NodeExpressions struct {
baseNode
Expressions []*NodeExpression
}
func (n *NodeExpressions) String() string {
return "NodeExpressions"
}
func (n *NodeExpressions) GetChildren() []Node {
children := make([]Node, 0, len(n.Expressions))
for _, child := range n.Expressions {
children = append(children, child)
}
return children
}
func (n *NodeExpressions) Accept(v Visitor) interface{} {
return v.VisitExpressions(n)
}
func NewNodeExpressions(text string, exprs []*NodeExpression) *NodeExpressions {
return &NodeExpressions{
baseNode: newBaseNode(text),
Expressions: exprs,
}
}

View File

@ -0,0 +1,51 @@
package planner
import "github.com/moznion/go-optional"
type NodeFromClause struct {
baseNode
TableSources []*NodeTableSource
Where optional.Option[*NodeExpression]
}
func (n *NodeFromClause) String() string {
return "NodeFromClause"
}
func (n *NodeFromClause) GetChildren() []Node {
children := make([]Node, 0, len(n.TableSources)+1)
for _, child := range n.TableSources {
children = append(children, child)
}
if n.Where.IsSome() {
children = append(children, n.Where.Unwrap())
}
return children
}
func (n *NodeFromClause) Accept(v Visitor) interface{} {
return v.VisitFromClause(n)
}
type NodeFromClauseOption func(*NodeFromClause)
func (n *NodeFromClause) apply(opts ...NodeFromClauseOption) {
for _, opt := range opts {
opt(n)
}
}
func WithWhere(where *NodeExpression) NodeFromClauseOption {
return func(n *NodeFromClause) {
n.Where = optional.Some(where)
}
}
func NewNodeFromClause(text string, tableSources []*NodeTableSource, opts ...NodeFromClauseOption) *NodeFromClause {
n := &NodeFromClause{
baseNode: newBaseNode(text),
TableSources: tableSources,
}
n.apply(opts...)
return n
}

View File

@ -0,0 +1,51 @@
package planner
import (
"fmt"
"github.com/moznion/go-optional"
)
type NodeFullColumnName struct {
baseNode
Name string
Alias optional.Option[string]
}
func (n *NodeFullColumnName) String() string {
if n.Alias.IsSome() {
return fmt.Sprintf("NodeFullColumnName, Name: %s, Alias: %s", n.Name, n.Alias.Unwrap())
}
return fmt.Sprintf("NodeFullColumnName, Name: %s", n.Name)
}
func (n *NodeFullColumnName) GetChildren() []Node {
return nil
}
func (n *NodeFullColumnName) Accept(v Visitor) interface{} {
return v.VisitFullColumnName(n)
}
type NodeFullColumnNameOption func(*NodeFullColumnName)
func (n *NodeFullColumnName) apply(opts ...NodeFullColumnNameOption) {
for _, opt := range opts {
opt(n)
}
}
func FullColumnNameWithAlias(alias string) NodeFullColumnNameOption {
return func(n *NodeFullColumnName) {
n.Alias = optional.Some(alias)
}
}
func NewNodeFullColumnName(text, name string, opts ...NodeFullColumnNameOption) *NodeFullColumnName {
n := &NodeFullColumnName{
baseNode: newBaseNode(text),
Name: name,
}
n.apply(opts...)
return n
}

View File

@ -0,0 +1,55 @@
package planner
import "github.com/moznion/go-optional"
type NodeFunctionCall struct {
baseNode
Agg optional.Option[*NodeAggregateWindowedFunction]
Alias optional.Option[string]
}
func (n *NodeFunctionCall) String() string {
if n.Alias.IsSome() {
return "NodeFunctionCall, Alias: " + n.Alias.Unwrap()
}
return "NodeFunctionCall"
}
func (n *NodeFunctionCall) GetChildren() []Node {
if n.Agg.IsSome() {
return []Node{n.Agg.Unwrap()}
}
return nil
}
func (n *NodeFunctionCall) Accept(v Visitor) interface{} {
return v.VisitFunctionCall(n)
}
type NodeFunctionCallOption func(*NodeFunctionCall)
func (n *NodeFunctionCall) apply(opts ...NodeFunctionCallOption) {
for _, opt := range opts {
opt(n)
}
}
func FunctionCallWithAlias(alias string) NodeFunctionCallOption {
return func(n *NodeFunctionCall) {
n.Alias = optional.Some(alias)
}
}
func WithAgg(agg *NodeAggregateWindowedFunction) NodeFunctionCallOption {
return func(n *NodeFunctionCall) {
n.Agg = optional.Some(agg)
}
}
func NewNodeFunctionCall(text string, opts ...NodeFunctionCallOption) *NodeFunctionCall {
n := &NodeFunctionCall{
baseNode: newBaseNode(text),
}
n.apply(opts...)
return n
}

View File

@ -0,0 +1,31 @@
package planner
import "fmt"
type NodeInPredicate struct {
baseNode
Predicate *NodePredicate
Expressions *NodeExpressions
Op InOperator
}
func (n *NodeInPredicate) String() string {
return fmt.Sprintf("NodeInPredicate, Op: %v", n.Op)
}
func (n *NodeInPredicate) GetChildren() []Node {
return []Node{n.Predicate, n.Expressions}
}
func (n *NodeInPredicate) Accept(v Visitor) interface{} {
return v.VisitInPredicate(n)
}
func NewNodeInPredicate(text string, predicate *NodePredicate, exprs *NodeExpressions, op InOperator) *NodeInPredicate {
return &NodeInPredicate{
baseNode: newBaseNode(text),
Predicate: predicate,
Expressions: exprs,
Op: op,
}
}

View File

@ -0,0 +1,32 @@
package planner
import "fmt"
type NodeIsExpression struct {
baseNode
Predicate *NodePredicate
TV TestValue
Op IsOperator
}
func (n *NodeIsExpression) String() string {
return fmt.Sprintf("NodeIsExpression, Op: %v, Test Value: %v", n.Op, n.TV)
}
func (n *NodeIsExpression) GetChildren() []Node {
return []Node{n.Predicate}
}
func (n *NodeIsExpression) Accept(v Visitor) interface{} {
return v.VisitIsExpression(n)
}
func NewNodeIsExpression(text string, predicate *NodePredicate, tv TestValue, op IsOperator) *NodeIsExpression {
n := &NodeIsExpression{
baseNode: newBaseNode(text),
Predicate: predicate,
TV: tv,
Op: op,
}
return n
}

View File

@ -0,0 +1,29 @@
package planner
import "fmt"
type NodeLimitClause struct {
baseNode
Limit int64
Offset int64
}
func (n *NodeLimitClause) String() string {
return fmt.Sprintf("Offet: %d, Limit: %d", n.Offset, n.Limit)
}
func (n *NodeLimitClause) GetChildren() []Node {
return nil
}
func (n *NodeLimitClause) Accept(v Visitor) interface{} {
return v.VisitLimitClause(n)
}
func NewNodeLimitClause(text string, limit, offset int64) *NodeLimitClause {
return &NodeLimitClause{
baseNode: newBaseNode(text),
Limit: limit,
Offset: offset,
}
}

View File

@ -0,0 +1,5 @@
package planner
type NodeLocalID struct {
Name string
}

View File

@ -0,0 +1,44 @@
package planner
type LockClauseOption int
const (
LockClauseOptionUnknown LockClauseOption = iota
LockClauseOptionForUpdate
LockClauseOptionLockInShareMode
)
func (o LockClauseOption) String() string {
switch o {
case LockClauseOptionForUpdate:
return "FOR UPDATE"
case LockClauseOptionLockInShareMode:
return "LOCK IN SHARE MODE"
default:
return "UNKNOWN"
}
}
type NodeLockClause struct {
baseNode
Option LockClauseOption
}
func (n *NodeLockClause) String() string {
return n.Option.String()
}
func (n *NodeLockClause) GetChildren() []Node {
return nil
}
func (n *NodeLockClause) Accept(v Visitor) interface{} {
return v.VisitLockClause(n)
}
func NewNodeLockClause(text string, option LockClauseOption) *NodeLockClause {
return &NodeLockClause{
baseNode: newBaseNode(text),
Option: option,
}
}

View File

@ -0,0 +1,31 @@
package planner
import "fmt"
type NodeLogicalExpression struct {
baseNode
Left *NodeExpression
Right *NodeExpression
Op LogicalOperator
}
func (n *NodeLogicalExpression) String() string {
return fmt.Sprintf("NodeLogicalExpression, Op: %v", n.Op)
}
func (n *NodeLogicalExpression) GetChildren() []Node {
return []Node{n.Left, n.Right}
}
func (n *NodeLogicalExpression) Accept(v Visitor) interface{} {
return v.VisitLogicalExpression(n)
}
func NewNodeLogicalExpression(text string, left, right *NodeExpression, op LogicalOperator) *NodeLogicalExpression {
return &NodeLogicalExpression{
baseNode: newBaseNode(text),
Left: left,
Right: right,
Op: op,
}
}

View File

@ -0,0 +1,29 @@
package planner
type NodeNestedExpressionAtom struct {
baseNode
Expressions []*NodeExpression
}
func (n *NodeNestedExpressionAtom) String() string {
return "NodeNestedExpressionAtom"
}
func (n *NodeNestedExpressionAtom) GetChildren() []Node {
children := make([]Node, 0, len(n.Expressions))
for _, child := range n.Expressions {
children = append(children, child)
}
return children
}
func (n *NodeNestedExpressionAtom) Accept(v Visitor) interface{} {
return v.VisitNestedExpressionAtom(n)
}
func NewNodeNestedExpressionAtom(text string, exprs []*NodeExpression) *NodeNestedExpressionAtom {
return &NodeNestedExpressionAtom{
baseNode: newBaseNode(text),
Expressions: exprs,
}
}

View File

@ -0,0 +1,22 @@
package planner
import "fmt"
type Node interface {
fmt.Stringer
GetText() string
GetChildren() []Node
Accept(visitor Visitor) interface{}
}
type baseNode struct {
text string
}
func (n baseNode) GetText() string {
return n.text
}
func newBaseNode(text string) baseNode {
return baseNode{text: text}
}

View File

@ -0,0 +1,25 @@
package planner
type NodeNotExpression struct {
baseNode
Expression *NodeExpression
}
func (n *NodeNotExpression) String() string {
return "NodeNotExpression"
}
func (n *NodeNotExpression) GetChildren() []Node {
return []Node{n.Expression}
}
func (n *NodeNotExpression) Accept(v Visitor) interface{} {
return v.VisitNotExpression(n)
}
func NewNodeNotExpression(text string, expr *NodeExpression) *NodeNotExpression {
return &NodeNotExpression{
baseNode: newBaseNode(text),
Expression: expr,
}
}

View File

@ -0,0 +1,3 @@
package planner
// TODO(longjiquan): better to use `one_of` to replace `optional`.

View File

@ -0,0 +1,117 @@
package planner
type UnaryOperator int
const (
UnaryOperatorUnknown UnaryOperator = iota
UnaryOperatorExclamationSymbol // '!'
UnaryOperatorTilde // '~'
UnaryOperatorPositive // '+'
UnaryOperatorNegative // '-'
UnaryOperatorNot // 'not'
)
func (o UnaryOperator) String() string {
switch o {
case UnaryOperatorExclamationSymbol:
return "!"
case UnaryOperatorTilde:
return "~"
case UnaryOperatorPositive:
return "+"
case UnaryOperatorNegative:
return "-"
case UnaryOperatorNot:
return "not"
default:
return "UNKNOWN"
}
}
type ComparisonOperator int
const (
ComparisonOperatorUnknown ComparisonOperator = 0
ComparisonOperatorEqual ComparisonOperator = 1 // '='
ComparisonOperatorGreaterThan ComparisonOperator = 2 // '>'
ComparisonOperatorLessThan ComparisonOperator = 4 // '<'
ComparisonOperatorNotEqual ComparisonOperator = 8 // '<>', '!='
ComparisonOperatorLessEqual = ComparisonOperatorLessThan | ComparisonOperatorEqual // '<='
ComparisonOperatorGreaterEqual = ComparisonOperatorGreaterThan | ComparisonOperatorEqual // '>='
)
func (o ComparisonOperator) String() string {
switch o {
case ComparisonOperatorEqual:
return "="
case ComparisonOperatorGreaterThan:
return ">"
case ComparisonOperatorLessThan:
return "<"
case ComparisonOperatorNotEqual:
return "!="
case ComparisonOperatorLessEqual:
return "<="
case ComparisonOperatorGreaterEqual:
return ">="
default:
return "UNKNOWN"
}
}
type LogicalOperator int
const (
LogicalOperatorUnknown LogicalOperator = iota
LogicalOperatorAnd
LogicalOperatorOr
)
func (o LogicalOperator) String() string {
switch o {
case LogicalOperatorAnd:
return "AND"
case LogicalOperatorOr:
return "OR"
default:
return "UNKNOWN"
}
}
type IsOperator int
const (
IsOperatorUnknown IsOperator = iota
IsOperatorIs
IsOperatorIsNot
)
func (o IsOperator) String() string {
switch o {
case IsOperatorIs:
return "IS"
case IsOperatorIsNot:
return "IS NOT"
default:
return "UNKNOWN"
}
}
type InOperator int
const (
InOperatorUnknown InOperator = iota
InOperatorIn
InOperatorNotIn
)
func (o InOperator) String() string {
switch o {
case InOperatorIn:
return "In"
case InOperatorNotIn:
return "NOT IN"
default:
return "UNKNOWN"
}
}

View File

@ -0,0 +1,9 @@
package planner
type LogicalPlan struct {
Node Node
}
type PhysicalPlan struct {
Node Node
}

View File

@ -0,0 +1,65 @@
package planner
import "github.com/moznion/go-optional"
type NodePredicate struct {
baseNode
InPredicate optional.Option[*NodeInPredicate]
BinaryComparisonPredicate optional.Option[*NodeBinaryComparisonPredicate]
ExpressionAtomPredicate optional.Option[*NodeExpressionAtomPredicate]
}
func (n *NodePredicate) String() string {
return "NodePredicate"
}
func (n *NodePredicate) GetChildren() []Node {
if n.InPredicate.IsSome() {
return []Node{n.InPredicate.Unwrap()}
}
if n.BinaryComparisonPredicate.IsSome() {
return []Node{n.BinaryComparisonPredicate.Unwrap()}
}
if n.ExpressionAtomPredicate.IsSome() {
return []Node{n.ExpressionAtomPredicate.Unwrap()}
}
return nil
}
func (n *NodePredicate) Accept(v Visitor) interface{} {
return v.VisitPredicate(n)
}
type NodePredicateOption func(*NodePredicate)
func (n *NodePredicate) apply(opts ...NodePredicateOption) {
for _, opt := range opts {
opt(n)
}
}
func WithInPredicate(p *NodeInPredicate) NodePredicateOption {
return func(n *NodePredicate) {
n.InPredicate = optional.Some(p)
}
}
func WithNodeBinaryComparisonPredicate(p *NodeBinaryComparisonPredicate) NodePredicateOption {
return func(n *NodePredicate) {
n.BinaryComparisonPredicate = optional.Some(p)
}
}
func WithNodeExpressionAtomPredicate(p *NodeExpressionAtomPredicate) NodePredicateOption {
return func(n *NodePredicate) {
n.ExpressionAtomPredicate = optional.Some(p)
}
}
func NewNodePredicate(text string, opts ...NodePredicateOption) *NodePredicate {
n := &NodePredicate{
baseNode: newBaseNode(text),
}
n.apply(opts...)
return n
}

View File

@ -0,0 +1,71 @@
package planner
import "github.com/moznion/go-optional"
type NodeQuerySpecification struct {
baseNode
SelectSpecs []*NodeSelectSpec
SelectElements []*NodeSelectElement
From optional.Option[*NodeFromClause]
Limit optional.Option[*NodeLimitClause]
}
func (n *NodeQuerySpecification) String() string {
return "NodeQuerySpecification"
}
func (n *NodeQuerySpecification) GetChildren() []Node {
children := make([]Node, 0, len(n.SelectSpecs)+len(n.SelectElements)+2)
for _, child := range n.SelectSpecs {
children = append(children, child)
}
for _, child := range n.SelectElements {
children = append(children, child)
}
if n.From.IsSome() {
children = append(children, n.From.Unwrap())
}
if n.Limit.IsSome() {
children = append(children, n.Limit.Unwrap())
}
return children
}
func (n *NodeQuerySpecification) Accept(v Visitor) interface{} {
return v.VisitQuerySpecification(n)
}
type NodeQuerySpecificationOption func(*NodeQuerySpecification)
func (n *NodeQuerySpecification) apply(opts ...NodeQuerySpecificationOption) {
for _, opt := range opts {
opt(n)
}
}
func WithFrom(from *NodeFromClause) NodeQuerySpecificationOption {
return func(n *NodeQuerySpecification) {
n.From = optional.Some(from)
}
}
func WithLimit(Limit *NodeLimitClause) NodeQuerySpecificationOption {
return func(n *NodeQuerySpecification) {
n.Limit = optional.Some(Limit)
}
}
func NewNodeQuerySpecification(
text string,
selectSpecs []*NodeSelectSpec,
selectElements []*NodeSelectElement,
opts ...NodeQuerySpecificationOption,
) *NodeQuerySpecification {
n := &NodeQuerySpecification{
baseNode: newBaseNode(text),
SelectSpecs: selectSpecs,
SelectElements: selectElements,
}
n.apply(opts...)
return n
}

View File

@ -0,0 +1,19 @@
package planner
type NodeSelectElementStar struct{} // select *;
func (n *NodeSelectElementStar) String() string {
return "NodeSelectElementStar"
}
func (n *NodeSelectElementStar) GetText() string {
return "*"
}
func (n *NodeSelectElementStar) GetChildren() []Node {
return nil
}
func (n *NodeSelectElementStar) Accept(v Visitor) interface{} {
return v.VisitSelectElementStar(n)
}

View File

@ -0,0 +1,65 @@
package planner
import "github.com/moznion/go-optional"
type NodeSelectElement struct {
baseNode
Star optional.Option[*NodeSelectElementStar]
FullColumnName optional.Option[*NodeFullColumnName]
FunctionCall optional.Option[*NodeFunctionCall]
}
func (n *NodeSelectElement) String() string {
return "NodeSelectElement"
}
func (n *NodeSelectElement) GetChildren() []Node {
if n.Star.IsSome() {
return []Node{n.Star.Unwrap()}
}
if n.FullColumnName.IsSome() {
return []Node{n.FullColumnName.Unwrap()}
}
if n.FunctionCall.IsSome() {
return []Node{n.FunctionCall.Unwrap()}
}
return nil
}
func (n *NodeSelectElement) Accept(v Visitor) interface{} {
return v.VisitSelectElement(n)
}
type NodeSelectElementOption func(*NodeSelectElement)
func (n *NodeSelectElement) apply(opts ...NodeSelectElementOption) {
for _, opt := range opts {
opt(n)
}
}
func WithStar() NodeSelectElementOption {
return func(n *NodeSelectElement) {
n.Star = optional.Some(&NodeSelectElementStar{})
}
}
func WithFullColumnName(c *NodeFullColumnName) NodeSelectElementOption {
return func(n *NodeSelectElement) {
n.FullColumnName = optional.Some(c)
}
}
func WithFunctionCall(c *NodeFunctionCall) NodeSelectElementOption {
return func(n *NodeSelectElement) {
n.FunctionCall = optional.Some(c)
}
}
func NewNodeSelectElement(text string, opts ...NodeSelectElementOption) *NodeSelectElement {
n := &NodeSelectElement{
baseNode: newBaseNode(text),
}
n.apply(opts...)
return n
}

View File

@ -0,0 +1,24 @@
package planner
type NodeSelectSpec struct {
baseNode
// TODO(longjiquan)
}
func (n *NodeSelectSpec) String() string {
return "NodeSelectSpec"
}
func (n *NodeSelectSpec) GetChildren() []Node {
return nil
}
func (n *NodeSelectSpec) Accept(v Visitor) interface{} {
return v.VisitSelectSpec(n)
}
func NewNodeSelectSpec(text string) *NodeSelectSpec {
return &NodeSelectSpec{
baseNode: newBaseNode(text),
}
}

View File

@ -0,0 +1,45 @@
package planner
import "github.com/moznion/go-optional"
type NodeSelectStatement struct {
baseNode
SimpleSelect optional.Option[*NodeSimpleSelect]
}
func (n *NodeSelectStatement) String() string {
return "NodeSelectStatement"
}
func (n *NodeSelectStatement) GetChildren() []Node {
if n.SimpleSelect.IsSome() {
return []Node{n.SimpleSelect.Unwrap()}
}
return nil
}
func (n *NodeSelectStatement) Accept(v Visitor) interface{} {
return v.VisitSelectStatement(n)
}
type NodeSelectStatementOption func(*NodeSelectStatement)
func (n *NodeSelectStatement) apply(opts ...NodeSelectStatementOption) {
for _, opt := range opts {
opt(n)
}
}
func WithSimpleSelect(s *NodeSimpleSelect) NodeSelectStatementOption {
return func(n *NodeSelectStatement) {
n.SimpleSelect = optional.Some(s)
}
}
func NewNodeSelectStatement(text string, opts ...NodeSelectStatementOption) *NodeSelectStatement {
n := &NodeSelectStatement{
baseNode: newBaseNode(text),
}
n.apply(opts...)
return n
}

View File

@ -0,0 +1,56 @@
package planner
import "github.com/moznion/go-optional"
type NodeSimpleSelect struct {
baseNode
Query optional.Option[*NodeQuerySpecification]
LockClause optional.Option[*NodeLockClause]
}
func (n *NodeSimpleSelect) String() string {
return "NodeSimpleSelect"
}
func (n *NodeSimpleSelect) GetChildren() []Node {
children := make([]Node, 0, 2)
if n.Query.IsSome() {
children = append(children, n.Query.Unwrap())
}
if n.LockClause.IsSome() {
children = append(children, n.LockClause.Unwrap())
}
return children
}
func (n *NodeSimpleSelect) Accept(v Visitor) interface{} {
return v.VisitSimpleSelect(n)
}
type NodeSimpleSelectOption func(*NodeSimpleSelect)
func (n *NodeSimpleSelect) apply(opts ...NodeSimpleSelectOption) {
for _, opt := range opts {
opt(n)
}
}
func WithQuery(query *NodeQuerySpecification) NodeSimpleSelectOption {
return func(n *NodeSimpleSelect) {
n.Query = optional.Some(query)
}
}
func WithLockClause(clause *NodeLockClause) NodeSimpleSelectOption {
return func(n *NodeSimpleSelect) {
n.LockClause = optional.Some(clause)
}
}
func NewNodeSimpleSelect(text string, opts ...NodeSimpleSelectOption) *NodeSimpleSelect {
n := &NodeSimpleSelect{
baseNode: newBaseNode(text),
}
n.apply(opts...)
return n
}

View File

@ -0,0 +1,45 @@
package planner
import "github.com/moznion/go-optional"
type NodeSqlStatement struct {
baseNode
DmlStatement optional.Option[*NodeDmlStatement]
}
func (n *NodeSqlStatement) String() string {
return "NodeSqlStatement"
}
func (n *NodeSqlStatement) GetChildren() []Node {
if n.DmlStatement.IsSome() {
return []Node{n.DmlStatement.Unwrap()}
}
return nil
}
func (n *NodeSqlStatement) Accept(v Visitor) interface{} {
return v.VisitSqlStatement(n)
}
type NodeSqlStatementOption func(*NodeSqlStatement)
func (n *NodeSqlStatement) apply(opts ...NodeSqlStatementOption) {
for _, opt := range opts {
opt(n)
}
}
func WithDmlStatement(s *NodeDmlStatement) NodeSqlStatementOption {
return func(n *NodeSqlStatement) {
n.DmlStatement = optional.Some(s)
}
}
func NewNodeSqlStatement(text string, opts ...NodeSqlStatementOption) *NodeSqlStatement {
n := &NodeSqlStatement{
baseNode: newBaseNode(text),
}
n.apply(opts...)
return n
}

View File

@ -0,0 +1,29 @@
package planner
type NodeSqlStatements struct {
baseNode
Statements []*NodeSqlStatement
}
func (n *NodeSqlStatements) String() string {
return "NodeSqlStatements"
}
func (n *NodeSqlStatements) GetChildren() []Node {
children := make([]Node, 0, len(n.Statements))
for _, child := range n.Statements {
children = append(children, child)
}
return children
}
func (n *NodeSqlStatements) Accept(v Visitor) interface{} {
return v.VisitSqlStatements(n)
}
func NewNodeSqlStatements(statements []*NodeSqlStatement, text string) *NodeSqlStatements {
return &NodeSqlStatements{
baseNode: newBaseNode(text),
Statements: statements,
}
}

View File

@ -0,0 +1,49 @@
package planner
import (
"fmt"
"github.com/moznion/go-optional"
)
type NodeTableSource struct {
baseNode
TableName optional.Option[string]
}
func (n *NodeTableSource) String() string {
if n.TableName.IsSome() {
return fmt.Sprintf("NodeTableSource: %s", n.TableName.Unwrap())
}
return "NodeTableSource"
}
func (n *NodeTableSource) GetChildren() []Node {
return nil
}
func (n *NodeTableSource) Accept(v Visitor) interface{} {
return v.VisitTableSource(n)
}
type NodeTableSourceOption func(*NodeTableSource)
func (n *NodeTableSource) apply(opts ...NodeTableSourceOption) {
for _, opt := range opts {
opt(n)
}
}
func WithTableName(name string) NodeTableSourceOption {
return func(n *NodeTableSource) {
n.TableName = optional.Some(name)
}
}
func NewNodeTableSource(text string, opts ...NodeTableSourceOption) *NodeTableSource {
n := &NodeTableSource{
baseNode: newBaseNode(text),
}
n.apply(opts...)
return n
}

View File

@ -0,0 +1,9 @@
package planner
type TestValue = int
const (
TestValueUnknown TestValue = iota
TestValueTrue
TestValueFalse
)

View File

@ -0,0 +1,60 @@
package planner
import (
"github.com/shivamMg/ppds/tree"
)
type TreeUtils interface {
PreOrderTraverse(n Node, v Visitor)
PrettyPrint(n Node)
PrettyPrintHr(n Node)
PrettyPrintHrn(n Node)
}
// wrappedNode implements tree.Node.
type wrappedNode struct {
n Node
}
func (w wrappedNode) Data() interface{} {
return w.n.String() + ", text: " + w.n.GetText()
}
func (w wrappedNode) Children() []tree.Node {
children := w.n.GetChildren()
r := make([]tree.Node, 0, len(children))
for _, child := range children {
r = append(r, newWrappedNode(child))
}
return r
}
func newWrappedNode(n Node) *wrappedNode {
return &wrappedNode{n: n}
}
type treeUtilsImpl struct{}
func (t treeUtilsImpl) PreOrderTraverse(n Node, v Visitor) {
n.Accept(v)
children := n.GetChildren()
for _, child := range children {
t.PreOrderTraverse(child, v)
}
}
func (t treeUtilsImpl) PrettyPrint(n Node) {
tree.Print(newWrappedNode(n))
}
func (t treeUtilsImpl) PrettyPrintHr(n Node) {
tree.PrintHr(newWrappedNode(n))
}
func (t treeUtilsImpl) PrettyPrintHrn(n Node) {
tree.PrintHrn(newWrappedNode(n))
}
func NewTreeUtils() TreeUtils {
return &treeUtilsImpl{}
}

View File

@ -0,0 +1,29 @@
package planner
import "fmt"
type NodeUnaryExpressionAtom struct {
baseNode
Expr *NodeExpressionAtom
Op UnaryOperator
}
func (n *NodeUnaryExpressionAtom) String() string {
return fmt.Sprintf("NodeUnaryExpressionAtom, Op: %v", n.Op)
}
func (n *NodeUnaryExpressionAtom) GetChildren() []Node {
return []Node{n.Expr}
}
func (n *NodeUnaryExpressionAtom) Accept(v Visitor) interface{} {
return v.VisitUnaryExpressionAtom(n)
}
func NewNodeUnaryExpressionAtom(text string, expr *NodeExpressionAtom, op UnaryOperator) *NodeUnaryExpressionAtom {
return &NodeUnaryExpressionAtom{
baseNode: newBaseNode(text),
Expr: expr,
Op: op,
}
}

View File

@ -0,0 +1,34 @@
package planner
type Visitor interface {
VisitSqlStatements(n *NodeSqlStatements) interface{}
VisitSqlStatement(n *NodeSqlStatement) interface{}
VisitDmlStatement(n *NodeDmlStatement) interface{}
VisitSelectStatement(n *NodeSelectStatement) interface{}
VisitSimpleSelect(n *NodeSimpleSelect) interface{}
VisitQuerySpecification(n *NodeQuerySpecification) interface{}
VisitLockClause(n *NodeLockClause) interface{}
VisitSelectSpec(n *NodeSelectSpec) interface{}
VisitSelectElement(n *NodeSelectElement) interface{}
VisitFromClause(n *NodeFromClause) interface{}
VisitLimitClause(n *NodeLimitClause) interface{}
VisitSelectElementStar(n *NodeSelectElementStar) interface{}
VisitFullColumnName(n *NodeFullColumnName) interface{}
VisitFunctionCall(n *NodeFunctionCall) interface{}
VisitAggregateWindowedFunction(n *NodeAggregateWindowedFunction) interface{}
VisitCount(n *NodeCount) interface{}
VisitTableSource(n *NodeTableSource) interface{}
VisitExpression(n *NodeExpression) interface{}
VisitExpressions(n *NodeExpressions) interface{}
VisitNotExpression(n *NodeNotExpression) interface{}
VisitLogicalExpression(n *NodeLogicalExpression) interface{}
VisitIsExpression(n *NodeIsExpression) interface{}
VisitPredicate(n *NodePredicate) interface{}
VisitInPredicate(n *NodeInPredicate) interface{}
VisitBinaryComparisonPredicate(n *NodeBinaryComparisonPredicate) interface{}
VisitExpressionAtomPredicate(n *NodeExpressionAtomPredicate) interface{}
VisitExpressionAtom(n *NodeExpressionAtom) interface{}
VisitUnaryExpressionAtom(n *NodeUnaryExpressionAtom) interface{}
VisitNestedExpressionAtom(n *NodeNestedExpressionAtom) interface{}
VisitConstant(n *NodeConstant) interface{}
}

62
internal/mysqld/server.go Normal file
View File

@ -0,0 +1,62 @@
package mysqld
import (
"fmt"
"sync"
"github.com/milvus-io/milvus/internal/types"
"github.com/xelabs/go-mysqlstack/driver"
"github.com/xelabs/go-mysqlstack/xlog"
"go.uber.org/zap/zapcore"
)
type Server struct {
listener *driver.Listener
wg sync.WaitGroup
}
func (s *Server) Start() error {
s.wg.Add(1)
go s.startInternalListener()
return nil
}
func (s *Server) startInternalListener() {
defer s.wg.Done()
s.listener.Accept()
}
func (s *Server) Close() error {
s.listener.Close()
s.wg.Wait()
return nil
}
func NewServer(s types.ProxyComponent, port int, level zapcore.Level) (*Server, error) {
var l = xlog.NewStdLog(xlog.Level(xlog.INFO))
switch level {
case zapcore.DebugLevel:
l = xlog.NewStdLog(xlog.Level(xlog.DEBUG))
case zapcore.InfoLevel:
l = xlog.NewStdLog(xlog.Level(xlog.INFO))
case zapcore.WarnLevel:
l = xlog.NewStdLog(xlog.Level(xlog.WARNING))
case zapcore.ErrorLevel:
l = xlog.NewStdLog(xlog.Level(xlog.ERROR))
case zapcore.FatalLevel:
l = xlog.NewStdLog(xlog.Level(xlog.FATAL))
case zapcore.PanicLevel:
l = xlog.NewStdLog(xlog.Level(xlog.PANIC))
}
addr := fmt.Sprintf(":%d", port)
h := newHandler(s)
listener, err := driver.NewListener(l, addr, h)
if err != nil {
return nil, err
}
r := &Server{listener: listener}
return r, nil
}

View File

@ -1,23 +0,0 @@
# Generate Parser with Antlr4
## Install Antlr4
Please follow [install antlr4](https://github.com/antlr/antlr4/blob/master/doc/go-target.md) to install the antlr tool.
The version of antlr tool: `4.9`.
## Code Generate
After you install the antlr4, you can generate the parser code in golang with:
```shell
export CLASSPATH=".:${PWD}/antlr-4.9-complete.jar:$CLASSPATH"
alias antlr4='java -Xmx500M -cp "${PWD}/antlr-4.9-complete.jar:$CLASSPATH" org.antlr.v4.Tool'
alias grun='java -Xmx500M -cp "${PWD}/antlr-4.9-complete.jar:$CLASSPATH" org.antlr.v4.gui.TestRig'
```
```shell
antlr4 -Dlanguage=Go -package planparserv2 -o generated -no-listener -visitor Plan.g4
```
All generated code will be under directory `generated`.

View File

@ -4,7 +4,7 @@ import (
"fmt"
"strconv"
"github.com/antlr/antlr4/runtime/Go/antlr"
"github.com/antlr/antlr4/runtime/Go/antlr/v4"
)
type errorListener struct {

View File

@ -83,4 +83,4 @@ expr
atn:
[3, 24715, 42794, 33075, 47597, 16764, 15335, 30598, 22884, 3, 39, 89, 4, 2, 9, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 5, 2, 17, 10, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 7, 2, 71, 10, 2, 12, 2, 14, 2, 74, 11, 2, 3, 2, 5, 2, 77, 10, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 7, 2, 84, 10, 2, 12, 2, 14, 2, 87, 11, 2, 3, 2, 2, 3, 2, 3, 2, 2, 11, 4, 2, 15, 16, 28, 29, 3, 2, 17, 19, 3, 2, 15, 16, 3, 2, 21, 22, 3, 2, 8, 9, 3, 2, 10, 11, 3, 2, 8, 11, 3, 2, 12, 13, 3, 2, 30, 31, 2, 111, 2, 16, 3, 2, 2, 2, 4, 5, 8, 2, 1, 2, 5, 17, 7, 34, 2, 2, 6, 17, 7, 35, 2, 2, 7, 17, 7, 33, 2, 2, 8, 17, 7, 37, 2, 2, 9, 17, 7, 36, 2, 2, 10, 11, 7, 3, 2, 2, 11, 12, 5, 2, 2, 2, 12, 13, 7, 4, 2, 2, 13, 17, 3, 2, 2, 2, 14, 15, 9, 2, 2, 2, 15, 17, 5, 2, 2, 17, 16, 4, 3, 2, 2, 2, 16, 6, 3, 2, 2, 2, 16, 7, 3, 2, 2, 2, 16, 8, 3, 2, 2, 2, 16, 9, 3, 2, 2, 2, 16, 10, 3, 2, 2, 2, 16, 14, 3, 2, 2, 2, 17, 85, 3, 2, 2, 2, 18, 19, 12, 18, 2, 2, 19, 20, 7, 20, 2, 2, 20, 84, 5, 2, 2, 19, 21, 22, 12, 16, 2, 2, 22, 23, 9, 3, 2, 2, 23, 84, 5, 2, 2, 17, 24, 25, 12, 15, 2, 2, 25, 26, 9, 4, 2, 2, 26, 84, 5, 2, 2, 16, 27, 28, 12, 14, 2, 2, 28, 29, 9, 5, 2, 2, 29, 84, 5, 2, 2, 15, 30, 31, 12, 11, 2, 2, 31, 32, 9, 6, 2, 2, 32, 33, 7, 36, 2, 2, 33, 34, 9, 6, 2, 2, 34, 84, 5, 2, 2, 12, 35, 36, 12, 10, 2, 2, 36, 37, 9, 7, 2, 2, 37, 38, 7, 36, 2, 2, 38, 39, 9, 7, 2, 2, 39, 84, 5, 2, 2, 11, 40, 41, 12, 9, 2, 2, 41, 42, 9, 8, 2, 2, 42, 84, 5, 2, 2, 10, 43, 44, 12, 8, 2, 2, 44, 45, 9, 9, 2, 2, 45, 84, 5, 2, 2, 9, 46, 47, 12, 7, 2, 2, 47, 48, 7, 23, 2, 2, 48, 84, 5, 2, 2, 8, 49, 50, 12, 6, 2, 2, 50, 51, 7, 25, 2, 2, 51, 84, 5, 2, 2, 7, 52, 53, 12, 5, 2, 2, 53, 54, 7, 24, 2, 2, 54, 84, 5, 2, 2, 6, 55, 56, 12, 4, 2, 2, 56, 57, 7, 26, 2, 2, 57, 84, 5, 2, 2, 5, 58, 59, 12, 3, 2, 2, 59, 60, 7, 27, 2, 2, 60, 84, 5, 2, 2, 4, 61, 62, 12, 19, 2, 2, 62, 63, 7, 14, 2, 2, 63, 84, 7, 37, 2, 2, 64, 65, 12, 13, 2, 2, 65, 66, 9, 10, 2, 2, 66, 67, 7, 5, 2, 2, 67, 72, 5, 2, 2, 2, 68, 69, 7, 6, 2, 2, 69, 71, 5, 2, 2, 2, 70, 68, 3, 2, 2, 2, 71, 74, 3, 2, 2, 2, 72, 70, 3, 2, 2, 2, 72, 73, 3, 2, 2, 2, 73, 76, 3, 2, 2, 2, 74, 72, 3, 2, 2, 2, 75, 77, 7, 6, 2, 2, 76, 75, 3, 2, 2, 2, 76, 77, 3, 2, 2, 2, 77, 78, 3, 2, 2, 2, 78, 79, 7, 7, 2, 2, 79, 84, 3, 2, 2, 2, 80, 81, 12, 12, 2, 2, 81, 82, 9, 10, 2, 2, 82, 84, 7, 32, 2, 2, 83, 18, 3, 2, 2, 2, 83, 21, 3, 2, 2, 2, 83, 24, 3, 2, 2, 2, 83, 27, 3, 2, 2, 2, 83, 30, 3, 2, 2, 2, 83, 35, 3, 2, 2, 2, 83, 40, 3, 2, 2, 2, 83, 43, 3, 2, 2, 2, 83, 46, 3, 2, 2, 2, 83, 49, 3, 2, 2, 2, 83, 52, 3, 2, 2, 2, 83, 55, 3, 2, 2, 2, 83, 58, 3, 2, 2, 2, 83, 61, 3, 2, 2, 2, 83, 64, 3, 2, 2, 2, 83, 80, 3, 2, 2, 2, 84, 87, 3, 2, 2, 2, 85, 83, 3, 2, 2, 2, 85, 86, 3, 2, 2, 2, 86, 3, 3, 2, 2, 2, 87, 85, 3, 2, 2, 2, 7, 16, 72, 76, 83, 85]
[4, 1, 37, 87, 2, 0, 7, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 3, 0, 15, 8, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 5, 0, 69, 8, 0, 10, 0, 12, 0, 72, 9, 0, 1, 0, 3, 0, 75, 8, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 5, 0, 82, 8, 0, 10, 0, 12, 0, 85, 9, 0, 1, 0, 0, 1, 0, 1, 0, 0, 9, 2, 0, 13, 14, 26, 27, 1, 0, 15, 17, 1, 0, 13, 14, 1, 0, 19, 20, 1, 0, 6, 7, 1, 0, 8, 9, 1, 0, 6, 9, 1, 0, 10, 11, 1, 0, 28, 29, 109, 0, 14, 1, 0, 0, 0, 2, 3, 6, 0, -1, 0, 3, 15, 5, 32, 0, 0, 4, 15, 5, 33, 0, 0, 5, 15, 5, 31, 0, 0, 6, 15, 5, 35, 0, 0, 7, 15, 5, 34, 0, 0, 8, 9, 5, 1, 0, 0, 9, 10, 3, 0, 0, 0, 10, 11, 5, 2, 0, 0, 11, 15, 1, 0, 0, 0, 12, 13, 7, 0, 0, 0, 13, 15, 3, 0, 0, 15, 14, 2, 1, 0, 0, 0, 14, 4, 1, 0, 0, 0, 14, 5, 1, 0, 0, 0, 14, 6, 1, 0, 0, 0, 14, 7, 1, 0, 0, 0, 14, 8, 1, 0, 0, 0, 14, 12, 1, 0, 0, 0, 15, 83, 1, 0, 0, 0, 16, 17, 10, 16, 0, 0, 17, 18, 5, 18, 0, 0, 18, 82, 3, 0, 0, 17, 19, 20, 10, 14, 0, 0, 20, 21, 7, 1, 0, 0, 21, 82, 3, 0, 0, 15, 22, 23, 10, 13, 0, 0, 23, 24, 7, 2, 0, 0, 24, 82, 3, 0, 0, 14, 25, 26, 10, 12, 0, 0, 26, 27, 7, 3, 0, 0, 27, 82, 3, 0, 0, 13, 28, 29, 10, 9, 0, 0, 29, 30, 7, 4, 0, 0, 30, 31, 5, 34, 0, 0, 31, 32, 7, 4, 0, 0, 32, 82, 3, 0, 0, 10, 33, 34, 10, 8, 0, 0, 34, 35, 7, 5, 0, 0, 35, 36, 5, 34, 0, 0, 36, 37, 7, 5, 0, 0, 37, 82, 3, 0, 0, 9, 38, 39, 10, 7, 0, 0, 39, 40, 7, 6, 0, 0, 40, 82, 3, 0, 0, 8, 41, 42, 10, 6, 0, 0, 42, 43, 7, 7, 0, 0, 43, 82, 3, 0, 0, 7, 44, 45, 10, 5, 0, 0, 45, 46, 5, 21, 0, 0, 46, 82, 3, 0, 0, 6, 47, 48, 10, 4, 0, 0, 48, 49, 5, 23, 0, 0, 49, 82, 3, 0, 0, 5, 50, 51, 10, 3, 0, 0, 51, 52, 5, 22, 0, 0, 52, 82, 3, 0, 0, 4, 53, 54, 10, 2, 0, 0, 54, 55, 5, 24, 0, 0, 55, 82, 3, 0, 0, 3, 56, 57, 10, 1, 0, 0, 57, 58, 5, 25, 0, 0, 58, 82, 3, 0, 0, 2, 59, 60, 10, 17, 0, 0, 60, 61, 5, 12, 0, 0, 61, 82, 5, 35, 0, 0, 62, 63, 10, 11, 0, 0, 63, 64, 7, 8, 0, 0, 64, 65, 5, 3, 0, 0, 65, 70, 3, 0, 0, 0, 66, 67, 5, 4, 0, 0, 67, 69, 3, 0, 0, 0, 68, 66, 1, 0, 0, 0, 69, 72, 1, 0, 0, 0, 70, 68, 1, 0, 0, 0, 70, 71, 1, 0, 0, 0, 71, 74, 1, 0, 0, 0, 72, 70, 1, 0, 0, 0, 73, 75, 5, 4, 0, 0, 74, 73, 1, 0, 0, 0, 74, 75, 1, 0, 0, 0, 75, 76, 1, 0, 0, 0, 76, 77, 5, 5, 0, 0, 77, 82, 1, 0, 0, 0, 78, 79, 10, 10, 0, 0, 79, 80, 7, 8, 0, 0, 80, 82, 5, 30, 0, 0, 81, 16, 1, 0, 0, 0, 81, 19, 1, 0, 0, 0, 81, 22, 1, 0, 0, 0, 81, 25, 1, 0, 0, 0, 81, 28, 1, 0, 0, 0, 81, 33, 1, 0, 0, 0, 81, 38, 1, 0, 0, 0, 81, 41, 1, 0, 0, 0, 81, 44, 1, 0, 0, 0, 81, 47, 1, 0, 0, 0, 81, 50, 1, 0, 0, 0, 81, 53, 1, 0, 0, 0, 81, 56, 1, 0, 0, 0, 81, 59, 1, 0, 0, 0, 81, 62, 1, 0, 0, 0, 81, 78, 1, 0, 0, 0, 82, 85, 1, 0, 0, 0, 83, 81, 1, 0, 0, 0, 83, 84, 1, 0, 0, 0, 84, 1, 1, 0, 0, 0, 85, 83, 1, 0, 0, 0, 5, 14, 70, 74, 81, 83]

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,3 @@
package planparserv2
//go:generate ./generate.sh

View File

@ -0,0 +1,4 @@
#!/bin/sh
alias antlr4='java -Xmx500M -cp "../../../../tools/antlr/antlr-4.11.1-complete.jar:$CLASSPATH" org.antlr.v4.Tool'
antlr4 -Dlanguage=Go -no-listener -visitor -package planparserv2 *.g4

View File

@ -1,7 +1,7 @@
// Code generated from Plan.g4 by ANTLR 4.9. DO NOT EDIT.
// Code generated from java-escape by ANTLR 4.11.1. DO NOT EDIT.
package planparserv2 // Plan
import "github.com/antlr/antlr4/runtime/Go/antlr"
import "github.com/antlr/antlr4/runtime/Go/antlr/v4"
type BasePlanVisitor struct {
*antlr.BaseParseTreeVisitor

View File

@ -1,261 +1,20 @@
// Code generated from Plan.g4 by ANTLR 4.9. DO NOT EDIT.
// Code generated from java-escape by ANTLR 4.11.1. DO NOT EDIT.
package planparserv2
import (
"fmt"
"sync"
"unicode"
"github.com/antlr/antlr4/runtime/Go/antlr"
"github.com/antlr/antlr4/runtime/Go/antlr/v4"
)
// Suppress unused import error
var _ = fmt.Printf
var _ = sync.Once{}
var _ = unicode.IsLetter
var serializedLexerAtn = []uint16{
3, 24715, 42794, 33075, 47597, 16764, 15335, 30598, 22884, 2, 39, 444,
8, 1, 4, 2, 9, 2, 4, 3, 9, 3, 4, 4, 9, 4, 4, 5, 9, 5, 4, 6, 9, 6, 4, 7,
9, 7, 4, 8, 9, 8, 4, 9, 9, 9, 4, 10, 9, 10, 4, 11, 9, 11, 4, 12, 9, 12,
4, 13, 9, 13, 4, 14, 9, 14, 4, 15, 9, 15, 4, 16, 9, 16, 4, 17, 9, 17, 4,
18, 9, 18, 4, 19, 9, 19, 4, 20, 9, 20, 4, 21, 9, 21, 4, 22, 9, 22, 4, 23,
9, 23, 4, 24, 9, 24, 4, 25, 9, 25, 4, 26, 9, 26, 4, 27, 9, 27, 4, 28, 9,
28, 4, 29, 9, 29, 4, 30, 9, 30, 4, 31, 9, 31, 4, 32, 9, 32, 4, 33, 9, 33,
4, 34, 9, 34, 4, 35, 9, 35, 4, 36, 9, 36, 4, 37, 9, 37, 4, 38, 9, 38, 4,
39, 9, 39, 4, 40, 9, 40, 4, 41, 9, 41, 4, 42, 9, 42, 4, 43, 9, 43, 4, 44,
9, 44, 4, 45, 9, 45, 4, 46, 9, 46, 4, 47, 9, 47, 4, 48, 9, 48, 4, 49, 9,
49, 4, 50, 9, 50, 4, 51, 9, 51, 4, 52, 9, 52, 4, 53, 9, 53, 4, 54, 9, 54,
4, 55, 9, 55, 4, 56, 9, 56, 4, 57, 9, 57, 4, 58, 9, 58, 4, 59, 9, 59, 4,
60, 9, 60, 4, 61, 9, 61, 3, 2, 3, 2, 3, 3, 3, 3, 3, 4, 3, 4, 3, 5, 3, 5,
3, 6, 3, 6, 3, 7, 3, 7, 3, 8, 3, 8, 3, 8, 3, 9, 3, 9, 3, 10, 3, 10, 3,
10, 3, 11, 3, 11, 3, 11, 3, 12, 3, 12, 3, 12, 3, 13, 3, 13, 3, 13, 3, 13,
3, 13, 3, 13, 3, 13, 3, 13, 5, 13, 158, 10, 13, 3, 14, 3, 14, 3, 15, 3,
15, 3, 16, 3, 16, 3, 17, 3, 17, 3, 18, 3, 18, 3, 19, 3, 19, 3, 19, 3, 20,
3, 20, 3, 20, 3, 21, 3, 21, 3, 21, 3, 22, 3, 22, 3, 23, 3, 23, 3, 24, 3,
24, 3, 25, 3, 25, 3, 25, 3, 25, 3, 25, 5, 25, 190, 10, 25, 3, 26, 3, 26,
3, 26, 3, 26, 5, 26, 196, 10, 26, 3, 27, 3, 27, 3, 28, 3, 28, 3, 28, 3,
28, 5, 28, 204, 10, 28, 3, 29, 3, 29, 3, 29, 3, 30, 3, 30, 3, 30, 3, 30,
3, 30, 3, 30, 3, 30, 3, 31, 3, 31, 3, 31, 7, 31, 219, 10, 31, 12, 31, 14,
31, 222, 11, 31, 3, 31, 3, 31, 3, 32, 3, 32, 3, 32, 3, 32, 3, 32, 3, 32,
3, 32, 3, 32, 3, 32, 3, 32, 3, 32, 3, 32, 3, 32, 3, 32, 3, 32, 3, 32, 3,
32, 3, 32, 3, 32, 3, 32, 3, 32, 3, 32, 3, 32, 3, 32, 3, 32, 3, 32, 3, 32,
5, 32, 253, 10, 32, 3, 33, 3, 33, 3, 33, 3, 33, 5, 33, 259, 10, 33, 3,
34, 3, 34, 5, 34, 263, 10, 34, 3, 35, 3, 35, 3, 35, 7, 35, 268, 10, 35,
12, 35, 14, 35, 271, 11, 35, 3, 36, 5, 36, 274, 10, 36, 3, 36, 3, 36, 5,
36, 278, 10, 36, 3, 36, 3, 36, 3, 37, 3, 37, 3, 37, 5, 37, 285, 10, 37,
3, 38, 6, 38, 288, 10, 38, 13, 38, 14, 38, 289, 3, 39, 3, 39, 3, 39, 3,
39, 3, 39, 3, 39, 3, 39, 5, 39, 299, 10, 39, 3, 40, 3, 40, 3, 41, 3, 41,
3, 42, 3, 42, 3, 42, 6, 42, 308, 10, 42, 13, 42, 14, 42, 309, 3, 43, 3,
43, 7, 43, 314, 10, 43, 12, 43, 14, 43, 317, 11, 43, 3, 44, 3, 44, 7, 44,
321, 10, 44, 12, 44, 14, 44, 324, 11, 44, 3, 45, 3, 45, 3, 45, 3, 45, 3,
46, 3, 46, 3, 47, 3, 47, 3, 48, 3, 48, 3, 49, 3, 49, 3, 49, 3, 49, 3, 49,
3, 50, 3, 50, 3, 50, 3, 50, 3, 50, 3, 50, 3, 50, 3, 50, 3, 50, 3, 50, 5,
50, 351, 10, 50, 3, 51, 3, 51, 5, 51, 355, 10, 51, 3, 51, 3, 51, 3, 51,
5, 51, 360, 10, 51, 3, 52, 3, 52, 3, 52, 3, 52, 5, 52, 366, 10, 52, 3,
52, 3, 52, 3, 53, 5, 53, 371, 10, 53, 3, 53, 3, 53, 3, 53, 3, 53, 3, 53,
5, 53, 378, 10, 53, 3, 54, 3, 54, 5, 54, 382, 10, 54, 3, 54, 3, 54, 3,
55, 6, 55, 387, 10, 55, 13, 55, 14, 55, 388, 3, 56, 5, 56, 392, 10, 56,
3, 56, 3, 56, 3, 56, 3, 56, 3, 56, 5, 56, 399, 10, 56, 3, 57, 6, 57, 402,
10, 57, 13, 57, 14, 57, 403, 3, 58, 3, 58, 5, 58, 408, 10, 58, 3, 58, 3,
58, 3, 59, 3, 59, 3, 59, 3, 59, 3, 59, 5, 59, 417, 10, 59, 3, 59, 5, 59,
420, 10, 59, 3, 59, 3, 59, 3, 59, 3, 59, 3, 59, 5, 59, 427, 10, 59, 3,
60, 6, 60, 430, 10, 60, 13, 60, 14, 60, 431, 3, 60, 3, 60, 3, 61, 3, 61,
5, 61, 438, 10, 61, 3, 61, 5, 61, 441, 10, 61, 3, 61, 3, 61, 2, 2, 62,
3, 3, 5, 4, 7, 5, 9, 6, 11, 7, 13, 8, 15, 9, 17, 10, 19, 11, 21, 12, 23,
13, 25, 14, 27, 15, 29, 16, 31, 17, 33, 18, 35, 19, 37, 20, 39, 21, 41,
22, 43, 23, 45, 24, 47, 25, 49, 26, 51, 27, 53, 28, 55, 29, 57, 30, 59,
31, 61, 32, 63, 33, 65, 34, 67, 35, 69, 36, 71, 37, 73, 2, 75, 2, 77, 2,
79, 2, 81, 2, 83, 2, 85, 2, 87, 2, 89, 2, 91, 2, 93, 2, 95, 2, 97, 2, 99,
2, 101, 2, 103, 2, 105, 2, 107, 2, 109, 2, 111, 2, 113, 2, 115, 2, 117,
2, 119, 38, 121, 39, 3, 2, 17, 5, 2, 78, 78, 87, 87, 119, 119, 6, 2, 12,
12, 15, 15, 36, 36, 94, 94, 5, 2, 67, 92, 97, 97, 99, 124, 3, 2, 50, 59,
4, 2, 68, 68, 100, 100, 3, 2, 50, 51, 4, 2, 90, 90, 122, 122, 3, 2, 51,
59, 3, 2, 50, 57, 5, 2, 50, 59, 67, 72, 99, 104, 4, 2, 71, 71, 103, 103,
4, 2, 45, 45, 47, 47, 4, 2, 82, 82, 114, 114, 12, 2, 36, 36, 41, 41, 65,
65, 94, 94, 99, 100, 104, 104, 112, 112, 116, 116, 118, 118, 120, 120,
4, 2, 11, 11, 34, 34, 2, 467, 2, 3, 3, 2, 2, 2, 2, 5, 3, 2, 2, 2, 2, 7,
3, 2, 2, 2, 2, 9, 3, 2, 2, 2, 2, 11, 3, 2, 2, 2, 2, 13, 3, 2, 2, 2, 2,
15, 3, 2, 2, 2, 2, 17, 3, 2, 2, 2, 2, 19, 3, 2, 2, 2, 2, 21, 3, 2, 2, 2,
2, 23, 3, 2, 2, 2, 2, 25, 3, 2, 2, 2, 2, 27, 3, 2, 2, 2, 2, 29, 3, 2, 2,
2, 2, 31, 3, 2, 2, 2, 2, 33, 3, 2, 2, 2, 2, 35, 3, 2, 2, 2, 2, 37, 3, 2,
2, 2, 2, 39, 3, 2, 2, 2, 2, 41, 3, 2, 2, 2, 2, 43, 3, 2, 2, 2, 2, 45, 3,
2, 2, 2, 2, 47, 3, 2, 2, 2, 2, 49, 3, 2, 2, 2, 2, 51, 3, 2, 2, 2, 2, 53,
3, 2, 2, 2, 2, 55, 3, 2, 2, 2, 2, 57, 3, 2, 2, 2, 2, 59, 3, 2, 2, 2, 2,
61, 3, 2, 2, 2, 2, 63, 3, 2, 2, 2, 2, 65, 3, 2, 2, 2, 2, 67, 3, 2, 2, 2,
2, 69, 3, 2, 2, 2, 2, 71, 3, 2, 2, 2, 2, 119, 3, 2, 2, 2, 2, 121, 3, 2,
2, 2, 3, 123, 3, 2, 2, 2, 5, 125, 3, 2, 2, 2, 7, 127, 3, 2, 2, 2, 9, 129,
3, 2, 2, 2, 11, 131, 3, 2, 2, 2, 13, 133, 3, 2, 2, 2, 15, 135, 3, 2, 2,
2, 17, 138, 3, 2, 2, 2, 19, 140, 3, 2, 2, 2, 21, 143, 3, 2, 2, 2, 23, 146,
3, 2, 2, 2, 25, 157, 3, 2, 2, 2, 27, 159, 3, 2, 2, 2, 29, 161, 3, 2, 2,
2, 31, 163, 3, 2, 2, 2, 33, 165, 3, 2, 2, 2, 35, 167, 3, 2, 2, 2, 37, 169,
3, 2, 2, 2, 39, 172, 3, 2, 2, 2, 41, 175, 3, 2, 2, 2, 43, 178, 3, 2, 2,
2, 45, 180, 3, 2, 2, 2, 47, 182, 3, 2, 2, 2, 49, 189, 3, 2, 2, 2, 51, 195,
3, 2, 2, 2, 53, 197, 3, 2, 2, 2, 55, 203, 3, 2, 2, 2, 57, 205, 3, 2, 2,
2, 59, 208, 3, 2, 2, 2, 61, 215, 3, 2, 2, 2, 63, 252, 3, 2, 2, 2, 65, 258,
3, 2, 2, 2, 67, 262, 3, 2, 2, 2, 69, 264, 3, 2, 2, 2, 71, 273, 3, 2, 2,
2, 73, 284, 3, 2, 2, 2, 75, 287, 3, 2, 2, 2, 77, 298, 3, 2, 2, 2, 79, 300,
3, 2, 2, 2, 81, 302, 3, 2, 2, 2, 83, 304, 3, 2, 2, 2, 85, 311, 3, 2, 2,
2, 87, 318, 3, 2, 2, 2, 89, 325, 3, 2, 2, 2, 91, 329, 3, 2, 2, 2, 93, 331,
3, 2, 2, 2, 95, 333, 3, 2, 2, 2, 97, 335, 3, 2, 2, 2, 99, 350, 3, 2, 2,
2, 101, 359, 3, 2, 2, 2, 103, 361, 3, 2, 2, 2, 105, 377, 3, 2, 2, 2, 107,
379, 3, 2, 2, 2, 109, 386, 3, 2, 2, 2, 111, 398, 3, 2, 2, 2, 113, 401,
3, 2, 2, 2, 115, 405, 3, 2, 2, 2, 117, 426, 3, 2, 2, 2, 119, 429, 3, 2,
2, 2, 121, 440, 3, 2, 2, 2, 123, 124, 7, 42, 2, 2, 124, 4, 3, 2, 2, 2,
125, 126, 7, 43, 2, 2, 126, 6, 3, 2, 2, 2, 127, 128, 7, 93, 2, 2, 128,
8, 3, 2, 2, 2, 129, 130, 7, 46, 2, 2, 130, 10, 3, 2, 2, 2, 131, 132, 7,
95, 2, 2, 132, 12, 3, 2, 2, 2, 133, 134, 7, 62, 2, 2, 134, 14, 3, 2, 2,
2, 135, 136, 7, 62, 2, 2, 136, 137, 7, 63, 2, 2, 137, 16, 3, 2, 2, 2, 138,
139, 7, 64, 2, 2, 139, 18, 3, 2, 2, 2, 140, 141, 7, 64, 2, 2, 141, 142,
7, 63, 2, 2, 142, 20, 3, 2, 2, 2, 143, 144, 7, 63, 2, 2, 144, 145, 7, 63,
2, 2, 145, 22, 3, 2, 2, 2, 146, 147, 7, 35, 2, 2, 147, 148, 7, 63, 2, 2,
148, 24, 3, 2, 2, 2, 149, 150, 7, 110, 2, 2, 150, 151, 7, 107, 2, 2, 151,
152, 7, 109, 2, 2, 152, 158, 7, 103, 2, 2, 153, 154, 7, 78, 2, 2, 154,
155, 7, 75, 2, 2, 155, 156, 7, 77, 2, 2, 156, 158, 7, 71, 2, 2, 157, 149,
3, 2, 2, 2, 157, 153, 3, 2, 2, 2, 158, 26, 3, 2, 2, 2, 159, 160, 7, 45,
2, 2, 160, 28, 3, 2, 2, 2, 161, 162, 7, 47, 2, 2, 162, 30, 3, 2, 2, 2,
163, 164, 7, 44, 2, 2, 164, 32, 3, 2, 2, 2, 165, 166, 7, 49, 2, 2, 166,
34, 3, 2, 2, 2, 167, 168, 7, 39, 2, 2, 168, 36, 3, 2, 2, 2, 169, 170, 7,
44, 2, 2, 170, 171, 7, 44, 2, 2, 171, 38, 3, 2, 2, 2, 172, 173, 7, 62,
2, 2, 173, 174, 7, 62, 2, 2, 174, 40, 3, 2, 2, 2, 175, 176, 7, 64, 2, 2,
176, 177, 7, 64, 2, 2, 177, 42, 3, 2, 2, 2, 178, 179, 7, 40, 2, 2, 179,
44, 3, 2, 2, 2, 180, 181, 7, 126, 2, 2, 181, 46, 3, 2, 2, 2, 182, 183,
7, 96, 2, 2, 183, 48, 3, 2, 2, 2, 184, 185, 7, 40, 2, 2, 185, 190, 7, 40,
2, 2, 186, 187, 7, 99, 2, 2, 187, 188, 7, 112, 2, 2, 188, 190, 7, 102,
2, 2, 189, 184, 3, 2, 2, 2, 189, 186, 3, 2, 2, 2, 190, 50, 3, 2, 2, 2,
191, 192, 7, 126, 2, 2, 192, 196, 7, 126, 2, 2, 193, 194, 7, 113, 2, 2,
194, 196, 7, 116, 2, 2, 195, 191, 3, 2, 2, 2, 195, 193, 3, 2, 2, 2, 196,
52, 3, 2, 2, 2, 197, 198, 7, 128, 2, 2, 198, 54, 3, 2, 2, 2, 199, 204,
7, 35, 2, 2, 200, 201, 7, 112, 2, 2, 201, 202, 7, 113, 2, 2, 202, 204,
7, 118, 2, 2, 203, 199, 3, 2, 2, 2, 203, 200, 3, 2, 2, 2, 204, 56, 3, 2,
2, 2, 205, 206, 7, 107, 2, 2, 206, 207, 7, 112, 2, 2, 207, 58, 3, 2, 2,
2, 208, 209, 7, 112, 2, 2, 209, 210, 7, 113, 2, 2, 210, 211, 7, 118, 2,
2, 211, 212, 7, 34, 2, 2, 212, 213, 7, 107, 2, 2, 213, 214, 7, 112, 2,
2, 214, 60, 3, 2, 2, 2, 215, 220, 7, 93, 2, 2, 216, 219, 5, 119, 60, 2,
217, 219, 5, 121, 61, 2, 218, 216, 3, 2, 2, 2, 218, 217, 3, 2, 2, 2, 219,
222, 3, 2, 2, 2, 220, 218, 3, 2, 2, 2, 220, 221, 3, 2, 2, 2, 221, 223,
3, 2, 2, 2, 222, 220, 3, 2, 2, 2, 223, 224, 7, 95, 2, 2, 224, 62, 3, 2,
2, 2, 225, 226, 7, 118, 2, 2, 226, 227, 7, 116, 2, 2, 227, 228, 7, 119,
2, 2, 228, 253, 7, 103, 2, 2, 229, 230, 7, 86, 2, 2, 230, 231, 7, 116,
2, 2, 231, 232, 7, 119, 2, 2, 232, 253, 7, 103, 2, 2, 233, 234, 7, 86,
2, 2, 234, 235, 7, 84, 2, 2, 235, 236, 7, 87, 2, 2, 236, 253, 7, 71, 2,
2, 237, 238, 7, 104, 2, 2, 238, 239, 7, 99, 2, 2, 239, 240, 7, 110, 2,
2, 240, 241, 7, 117, 2, 2, 241, 253, 7, 103, 2, 2, 242, 243, 7, 72, 2,
2, 243, 244, 7, 99, 2, 2, 244, 245, 7, 110, 2, 2, 245, 246, 7, 117, 2,
2, 246, 253, 7, 103, 2, 2, 247, 248, 7, 72, 2, 2, 248, 249, 7, 67, 2, 2,
249, 250, 7, 78, 2, 2, 250, 251, 7, 85, 2, 2, 251, 253, 7, 71, 2, 2, 252,
225, 3, 2, 2, 2, 252, 229, 3, 2, 2, 2, 252, 233, 3, 2, 2, 2, 252, 237,
3, 2, 2, 2, 252, 242, 3, 2, 2, 2, 252, 247, 3, 2, 2, 2, 253, 64, 3, 2,
2, 2, 254, 259, 5, 85, 43, 2, 255, 259, 5, 87, 44, 2, 256, 259, 5, 89,
45, 2, 257, 259, 5, 83, 42, 2, 258, 254, 3, 2, 2, 2, 258, 255, 3, 2, 2,
2, 258, 256, 3, 2, 2, 2, 258, 257, 3, 2, 2, 2, 259, 66, 3, 2, 2, 2, 260,
263, 5, 101, 51, 2, 261, 263, 5, 103, 52, 2, 262, 260, 3, 2, 2, 2, 262,
261, 3, 2, 2, 2, 263, 68, 3, 2, 2, 2, 264, 269, 5, 79, 40, 2, 265, 268,
5, 79, 40, 2, 266, 268, 5, 81, 41, 2, 267, 265, 3, 2, 2, 2, 267, 266, 3,
2, 2, 2, 268, 271, 3, 2, 2, 2, 269, 267, 3, 2, 2, 2, 269, 270, 3, 2, 2,
2, 270, 70, 3, 2, 2, 2, 271, 269, 3, 2, 2, 2, 272, 274, 5, 73, 37, 2, 273,
272, 3, 2, 2, 2, 273, 274, 3, 2, 2, 2, 274, 275, 3, 2, 2, 2, 275, 277,
7, 36, 2, 2, 276, 278, 5, 75, 38, 2, 277, 276, 3, 2, 2, 2, 277, 278, 3,
2, 2, 2, 278, 279, 3, 2, 2, 2, 279, 280, 7, 36, 2, 2, 280, 72, 3, 2, 2,
2, 281, 282, 7, 119, 2, 2, 282, 285, 7, 58, 2, 2, 283, 285, 9, 2, 2, 2,
284, 281, 3, 2, 2, 2, 284, 283, 3, 2, 2, 2, 285, 74, 3, 2, 2, 2, 286, 288,
5, 77, 39, 2, 287, 286, 3, 2, 2, 2, 288, 289, 3, 2, 2, 2, 289, 287, 3,
2, 2, 2, 289, 290, 3, 2, 2, 2, 290, 76, 3, 2, 2, 2, 291, 299, 10, 3, 2,
2, 292, 299, 5, 117, 59, 2, 293, 294, 7, 94, 2, 2, 294, 299, 7, 12, 2,
2, 295, 296, 7, 94, 2, 2, 296, 297, 7, 15, 2, 2, 297, 299, 7, 12, 2, 2,
298, 291, 3, 2, 2, 2, 298, 292, 3, 2, 2, 2, 298, 293, 3, 2, 2, 2, 298,
295, 3, 2, 2, 2, 299, 78, 3, 2, 2, 2, 300, 301, 9, 4, 2, 2, 301, 80, 3,
2, 2, 2, 302, 303, 9, 5, 2, 2, 303, 82, 3, 2, 2, 2, 304, 305, 7, 50, 2,
2, 305, 307, 9, 6, 2, 2, 306, 308, 9, 7, 2, 2, 307, 306, 3, 2, 2, 2, 308,
309, 3, 2, 2, 2, 309, 307, 3, 2, 2, 2, 309, 310, 3, 2, 2, 2, 310, 84, 3,
2, 2, 2, 311, 315, 5, 91, 46, 2, 312, 314, 5, 81, 41, 2, 313, 312, 3, 2,
2, 2, 314, 317, 3, 2, 2, 2, 315, 313, 3, 2, 2, 2, 315, 316, 3, 2, 2, 2,
316, 86, 3, 2, 2, 2, 317, 315, 3, 2, 2, 2, 318, 322, 7, 50, 2, 2, 319,
321, 5, 93, 47, 2, 320, 319, 3, 2, 2, 2, 321, 324, 3, 2, 2, 2, 322, 320,
3, 2, 2, 2, 322, 323, 3, 2, 2, 2, 323, 88, 3, 2, 2, 2, 324, 322, 3, 2,
2, 2, 325, 326, 7, 50, 2, 2, 326, 327, 9, 8, 2, 2, 327, 328, 5, 113, 57,
2, 328, 90, 3, 2, 2, 2, 329, 330, 9, 9, 2, 2, 330, 92, 3, 2, 2, 2, 331,
332, 9, 10, 2, 2, 332, 94, 3, 2, 2, 2, 333, 334, 9, 11, 2, 2, 334, 96,
3, 2, 2, 2, 335, 336, 5, 95, 48, 2, 336, 337, 5, 95, 48, 2, 337, 338, 5,
95, 48, 2, 338, 339, 5, 95, 48, 2, 339, 98, 3, 2, 2, 2, 340, 341, 7, 94,
2, 2, 341, 342, 7, 119, 2, 2, 342, 343, 3, 2, 2, 2, 343, 351, 5, 97, 49,
2, 344, 345, 7, 94, 2, 2, 345, 346, 7, 87, 2, 2, 346, 347, 3, 2, 2, 2,
347, 348, 5, 97, 49, 2, 348, 349, 5, 97, 49, 2, 349, 351, 3, 2, 2, 2, 350,
340, 3, 2, 2, 2, 350, 344, 3, 2, 2, 2, 351, 100, 3, 2, 2, 2, 352, 354,
5, 105, 53, 2, 353, 355, 5, 107, 54, 2, 354, 353, 3, 2, 2, 2, 354, 355,
3, 2, 2, 2, 355, 360, 3, 2, 2, 2, 356, 357, 5, 109, 55, 2, 357, 358, 5,
107, 54, 2, 358, 360, 3, 2, 2, 2, 359, 352, 3, 2, 2, 2, 359, 356, 3, 2,
2, 2, 360, 102, 3, 2, 2, 2, 361, 362, 7, 50, 2, 2, 362, 365, 9, 8, 2, 2,
363, 366, 5, 111, 56, 2, 364, 366, 5, 113, 57, 2, 365, 363, 3, 2, 2, 2,
365, 364, 3, 2, 2, 2, 366, 367, 3, 2, 2, 2, 367, 368, 5, 115, 58, 2, 368,
104, 3, 2, 2, 2, 369, 371, 5, 109, 55, 2, 370, 369, 3, 2, 2, 2, 370, 371,
3, 2, 2, 2, 371, 372, 3, 2, 2, 2, 372, 373, 7, 48, 2, 2, 373, 378, 5, 109,
55, 2, 374, 375, 5, 109, 55, 2, 375, 376, 7, 48, 2, 2, 376, 378, 3, 2,
2, 2, 377, 370, 3, 2, 2, 2, 377, 374, 3, 2, 2, 2, 378, 106, 3, 2, 2, 2,
379, 381, 9, 12, 2, 2, 380, 382, 9, 13, 2, 2, 381, 380, 3, 2, 2, 2, 381,
382, 3, 2, 2, 2, 382, 383, 3, 2, 2, 2, 383, 384, 5, 109, 55, 2, 384, 108,
3, 2, 2, 2, 385, 387, 5, 81, 41, 2, 386, 385, 3, 2, 2, 2, 387, 388, 3,
2, 2, 2, 388, 386, 3, 2, 2, 2, 388, 389, 3, 2, 2, 2, 389, 110, 3, 2, 2,
2, 390, 392, 5, 113, 57, 2, 391, 390, 3, 2, 2, 2, 391, 392, 3, 2, 2, 2,
392, 393, 3, 2, 2, 2, 393, 394, 7, 48, 2, 2, 394, 399, 5, 113, 57, 2, 395,
396, 5, 113, 57, 2, 396, 397, 7, 48, 2, 2, 397, 399, 3, 2, 2, 2, 398, 391,
3, 2, 2, 2, 398, 395, 3, 2, 2, 2, 399, 112, 3, 2, 2, 2, 400, 402, 5, 95,
48, 2, 401, 400, 3, 2, 2, 2, 402, 403, 3, 2, 2, 2, 403, 401, 3, 2, 2, 2,
403, 404, 3, 2, 2, 2, 404, 114, 3, 2, 2, 2, 405, 407, 9, 14, 2, 2, 406,
408, 9, 13, 2, 2, 407, 406, 3, 2, 2, 2, 407, 408, 3, 2, 2, 2, 408, 409,
3, 2, 2, 2, 409, 410, 5, 109, 55, 2, 410, 116, 3, 2, 2, 2, 411, 412, 7,
94, 2, 2, 412, 427, 9, 15, 2, 2, 413, 414, 7, 94, 2, 2, 414, 416, 5, 93,
47, 2, 415, 417, 5, 93, 47, 2, 416, 415, 3, 2, 2, 2, 416, 417, 3, 2, 2,
2, 417, 419, 3, 2, 2, 2, 418, 420, 5, 93, 47, 2, 419, 418, 3, 2, 2, 2,
419, 420, 3, 2, 2, 2, 420, 427, 3, 2, 2, 2, 421, 422, 7, 94, 2, 2, 422,
423, 7, 122, 2, 2, 423, 424, 3, 2, 2, 2, 424, 427, 5, 113, 57, 2, 425,
427, 5, 99, 50, 2, 426, 411, 3, 2, 2, 2, 426, 413, 3, 2, 2, 2, 426, 421,
3, 2, 2, 2, 426, 425, 3, 2, 2, 2, 427, 118, 3, 2, 2, 2, 428, 430, 9, 16,
2, 2, 429, 428, 3, 2, 2, 2, 430, 431, 3, 2, 2, 2, 431, 429, 3, 2, 2, 2,
431, 432, 3, 2, 2, 2, 432, 433, 3, 2, 2, 2, 433, 434, 8, 60, 2, 2, 434,
120, 3, 2, 2, 2, 435, 437, 7, 15, 2, 2, 436, 438, 7, 12, 2, 2, 437, 436,
3, 2, 2, 2, 437, 438, 3, 2, 2, 2, 438, 441, 3, 2, 2, 2, 439, 441, 7, 12,
2, 2, 440, 435, 3, 2, 2, 2, 440, 439, 3, 2, 2, 2, 441, 442, 3, 2, 2, 2,
442, 443, 8, 61, 2, 2, 443, 122, 3, 2, 2, 2, 40, 2, 157, 189, 195, 203,
218, 220, 252, 258, 262, 267, 269, 273, 277, 284, 289, 298, 309, 315, 322,
350, 354, 359, 365, 370, 377, 381, 388, 391, 398, 403, 407, 416, 419, 426,
431, 437, 440, 3, 8, 2, 2,
}
var lexerChannelNames = []string{
"DEFAULT_TOKEN_CHANNEL", "HIDDEN",
}
var lexerModeNames = []string{
"DEFAULT_MODE",
}
var lexerLiteralNames = []string{
"", "'('", "')'", "'['", "','", "']'", "'<'", "'<='", "'>'", "'>='", "'=='",
"'!='", "", "'+'", "'-'", "'*'", "'/'", "'%'", "'**'", "'<<'", "'>>'",
"'&'", "'|'", "'^'", "", "", "'~'", "", "'in'", "'not in'",
}
var lexerSymbolicNames = []string{
"", "", "", "", "", "", "LT", "LE", "GT", "GE", "EQ", "NE", "LIKE", "ADD",
"SUB", "MUL", "DIV", "MOD", "POW", "SHL", "SHR", "BAND", "BOR", "BXOR",
"AND", "OR", "BNOT", "NOT", "IN", "NIN", "EmptyTerm", "BooleanConstant",
"IntegerConstant", "FloatingConstant", "Identifier", "StringLiteral", "Whitespace",
"Newline",
}
var lexerRuleNames = []string{
"T__0", "T__1", "T__2", "T__3", "T__4", "LT", "LE", "GT", "GE", "EQ", "NE",
"LIKE", "ADD", "SUB", "MUL", "DIV", "MOD", "POW", "SHL", "SHR", "BAND",
"BOR", "BXOR", "AND", "OR", "BNOT", "NOT", "IN", "NIN", "EmptyTerm", "BooleanConstant",
"IntegerConstant", "FloatingConstant", "Identifier", "StringLiteral", "EncodingPrefix",
"SCharSequence", "SChar", "Nondigit", "Digit", "BinaryConstant", "DecimalConstant",
"OctalConstant", "HexadecimalConstant", "NonzeroDigit", "OctalDigit", "HexadecimalDigit",
"HexQuad", "UniversalCharacterName", "DecimalFloatingConstant", "HexadecimalFloatingConstant",
"FractionalConstant", "ExponentPart", "DigitSequence", "HexadecimalFractionalConstant",
"HexadecimalDigitSequence", "BinaryExponentPart", "EscapeSequence", "Whitespace",
"Newline",
}
type PlanLexer struct {
*antlr.BaseLexer
channelNames []string
@ -263,28 +22,288 @@ type PlanLexer struct {
// TODO: EOF string
}
// NewPlanLexer produces a new lexer instance for the optional input antlr.CharStream.
//
// The *PlanLexer instance produced may be reused by calling the SetInputStream method.
// The initial lexer configuration is expensive to construct, and the object is not thread-safe;
// however, if used within a Golang sync.Pool, the construction cost amortizes well and the
// objects can be used in a thread-safe manner.
func NewPlanLexer(input antlr.CharStream) *PlanLexer {
l := new(PlanLexer)
lexerDeserializer := antlr.NewATNDeserializer(nil)
lexerAtn := lexerDeserializer.DeserializeFromUInt16(serializedLexerAtn)
lexerDecisionToDFA := make([]*antlr.DFA, len(lexerAtn.DecisionToState))
for index, ds := range lexerAtn.DecisionToState {
lexerDecisionToDFA[index] = antlr.NewDFA(ds, index)
}
l.BaseLexer = antlr.NewBaseLexer(input)
l.Interpreter = antlr.NewLexerATNSimulator(l, lexerAtn, lexerDecisionToDFA, antlr.NewPredictionContextCache())
var planlexerLexerStaticData struct {
once sync.Once
serializedATN []int32
channelNames []string
modeNames []string
literalNames []string
symbolicNames []string
ruleNames []string
predictionContextCache *antlr.PredictionContextCache
atn *antlr.ATN
decisionToDFA []*antlr.DFA
}
l.channelNames = lexerChannelNames
l.modeNames = lexerModeNames
l.RuleNames = lexerRuleNames
l.LiteralNames = lexerLiteralNames
l.SymbolicNames = lexerSymbolicNames
func planlexerLexerInit() {
staticData := &planlexerLexerStaticData
staticData.channelNames = []string{
"DEFAULT_TOKEN_CHANNEL", "HIDDEN",
}
staticData.modeNames = []string{
"DEFAULT_MODE",
}
staticData.literalNames = []string{
"", "'('", "')'", "'['", "','", "']'", "'<'", "'<='", "'>'", "'>='",
"'=='", "'!='", "", "'+'", "'-'", "'*'", "'/'", "'%'", "'**'", "'<<'",
"'>>'", "'&'", "'|'", "'^'", "", "", "'~'", "", "'in'", "'not in'",
}
staticData.symbolicNames = []string{
"", "", "", "", "", "", "LT", "LE", "GT", "GE", "EQ", "NE", "LIKE",
"ADD", "SUB", "MUL", "DIV", "MOD", "POW", "SHL", "SHR", "BAND", "BOR",
"BXOR", "AND", "OR", "BNOT", "NOT", "IN", "NIN", "EmptyTerm", "BooleanConstant",
"IntegerConstant", "FloatingConstant", "Identifier", "StringLiteral",
"Whitespace", "Newline",
}
staticData.ruleNames = []string{
"T__0", "T__1", "T__2", "T__3", "T__4", "LT", "LE", "GT", "GE", "EQ",
"NE", "LIKE", "ADD", "SUB", "MUL", "DIV", "MOD", "POW", "SHL", "SHR",
"BAND", "BOR", "BXOR", "AND", "OR", "BNOT", "NOT", "IN", "NIN", "EmptyTerm",
"BooleanConstant", "IntegerConstant", "FloatingConstant", "Identifier",
"StringLiteral", "EncodingPrefix", "SCharSequence", "SChar", "Nondigit",
"Digit", "BinaryConstant", "DecimalConstant", "OctalConstant", "HexadecimalConstant",
"NonzeroDigit", "OctalDigit", "HexadecimalDigit", "HexQuad", "UniversalCharacterName",
"DecimalFloatingConstant", "HexadecimalFloatingConstant", "FractionalConstant",
"ExponentPart", "DigitSequence", "HexadecimalFractionalConstant", "HexadecimalDigitSequence",
"BinaryExponentPart", "EscapeSequence", "Whitespace", "Newline",
}
staticData.predictionContextCache = antlr.NewPredictionContextCache()
staticData.serializedATN = []int32{
4, 0, 37, 442, 6, -1, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 2,
4, 7, 4, 2, 5, 7, 5, 2, 6, 7, 6, 2, 7, 7, 7, 2, 8, 7, 8, 2, 9, 7, 9, 2,
10, 7, 10, 2, 11, 7, 11, 2, 12, 7, 12, 2, 13, 7, 13, 2, 14, 7, 14, 2, 15,
7, 15, 2, 16, 7, 16, 2, 17, 7, 17, 2, 18, 7, 18, 2, 19, 7, 19, 2, 20, 7,
20, 2, 21, 7, 21, 2, 22, 7, 22, 2, 23, 7, 23, 2, 24, 7, 24, 2, 25, 7, 25,
2, 26, 7, 26, 2, 27, 7, 27, 2, 28, 7, 28, 2, 29, 7, 29, 2, 30, 7, 30, 2,
31, 7, 31, 2, 32, 7, 32, 2, 33, 7, 33, 2, 34, 7, 34, 2, 35, 7, 35, 2, 36,
7, 36, 2, 37, 7, 37, 2, 38, 7, 38, 2, 39, 7, 39, 2, 40, 7, 40, 2, 41, 7,
41, 2, 42, 7, 42, 2, 43, 7, 43, 2, 44, 7, 44, 2, 45, 7, 45, 2, 46, 7, 46,
2, 47, 7, 47, 2, 48, 7, 48, 2, 49, 7, 49, 2, 50, 7, 50, 2, 51, 7, 51, 2,
52, 7, 52, 2, 53, 7, 53, 2, 54, 7, 54, 2, 55, 7, 55, 2, 56, 7, 56, 2, 57,
7, 57, 2, 58, 7, 58, 2, 59, 7, 59, 1, 0, 1, 0, 1, 1, 1, 1, 1, 2, 1, 2,
1, 3, 1, 3, 1, 4, 1, 4, 1, 5, 1, 5, 1, 6, 1, 6, 1, 6, 1, 7, 1, 7, 1, 8,
1, 8, 1, 8, 1, 9, 1, 9, 1, 9, 1, 10, 1, 10, 1, 10, 1, 11, 1, 11, 1, 11,
1, 11, 1, 11, 1, 11, 1, 11, 1, 11, 3, 11, 156, 8, 11, 1, 12, 1, 12, 1,
13, 1, 13, 1, 14, 1, 14, 1, 15, 1, 15, 1, 16, 1, 16, 1, 17, 1, 17, 1, 17,
1, 18, 1, 18, 1, 18, 1, 19, 1, 19, 1, 19, 1, 20, 1, 20, 1, 21, 1, 21, 1,
22, 1, 22, 1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 3, 23, 188, 8, 23, 1, 24,
1, 24, 1, 24, 1, 24, 3, 24, 194, 8, 24, 1, 25, 1, 25, 1, 26, 1, 26, 1,
26, 1, 26, 3, 26, 202, 8, 26, 1, 27, 1, 27, 1, 27, 1, 28, 1, 28, 1, 28,
1, 28, 1, 28, 1, 28, 1, 28, 1, 29, 1, 29, 1, 29, 5, 29, 217, 8, 29, 10,
29, 12, 29, 220, 9, 29, 1, 29, 1, 29, 1, 30, 1, 30, 1, 30, 1, 30, 1, 30,
1, 30, 1, 30, 1, 30, 1, 30, 1, 30, 1, 30, 1, 30, 1, 30, 1, 30, 1, 30, 1,
30, 1, 30, 1, 30, 1, 30, 1, 30, 1, 30, 1, 30, 1, 30, 1, 30, 1, 30, 1, 30,
1, 30, 3, 30, 251, 8, 30, 1, 31, 1, 31, 1, 31, 1, 31, 3, 31, 257, 8, 31,
1, 32, 1, 32, 3, 32, 261, 8, 32, 1, 33, 1, 33, 1, 33, 5, 33, 266, 8, 33,
10, 33, 12, 33, 269, 9, 33, 1, 34, 3, 34, 272, 8, 34, 1, 34, 1, 34, 3,
34, 276, 8, 34, 1, 34, 1, 34, 1, 35, 1, 35, 1, 35, 3, 35, 283, 8, 35, 1,
36, 4, 36, 286, 8, 36, 11, 36, 12, 36, 287, 1, 37, 1, 37, 1, 37, 1, 37,
1, 37, 1, 37, 1, 37, 3, 37, 297, 8, 37, 1, 38, 1, 38, 1, 39, 1, 39, 1,
40, 1, 40, 1, 40, 4, 40, 306, 8, 40, 11, 40, 12, 40, 307, 1, 41, 1, 41,
5, 41, 312, 8, 41, 10, 41, 12, 41, 315, 9, 41, 1, 42, 1, 42, 5, 42, 319,
8, 42, 10, 42, 12, 42, 322, 9, 42, 1, 43, 1, 43, 1, 43, 1, 43, 1, 44, 1,
44, 1, 45, 1, 45, 1, 46, 1, 46, 1, 47, 1, 47, 1, 47, 1, 47, 1, 47, 1, 48,
1, 48, 1, 48, 1, 48, 1, 48, 1, 48, 1, 48, 1, 48, 1, 48, 1, 48, 3, 48, 349,
8, 48, 1, 49, 1, 49, 3, 49, 353, 8, 49, 1, 49, 1, 49, 1, 49, 3, 49, 358,
8, 49, 1, 50, 1, 50, 1, 50, 1, 50, 3, 50, 364, 8, 50, 1, 50, 1, 50, 1,
51, 3, 51, 369, 8, 51, 1, 51, 1, 51, 1, 51, 1, 51, 1, 51, 3, 51, 376, 8,
51, 1, 52, 1, 52, 3, 52, 380, 8, 52, 1, 52, 1, 52, 1, 53, 4, 53, 385, 8,
53, 11, 53, 12, 53, 386, 1, 54, 3, 54, 390, 8, 54, 1, 54, 1, 54, 1, 54,
1, 54, 1, 54, 3, 54, 397, 8, 54, 1, 55, 4, 55, 400, 8, 55, 11, 55, 12,
55, 401, 1, 56, 1, 56, 3, 56, 406, 8, 56, 1, 56, 1, 56, 1, 57, 1, 57, 1,
57, 1, 57, 1, 57, 3, 57, 415, 8, 57, 1, 57, 3, 57, 418, 8, 57, 1, 57, 1,
57, 1, 57, 1, 57, 1, 57, 3, 57, 425, 8, 57, 1, 58, 4, 58, 428, 8, 58, 11,
58, 12, 58, 429, 1, 58, 1, 58, 1, 59, 1, 59, 3, 59, 436, 8, 59, 1, 59,
3, 59, 439, 8, 59, 1, 59, 1, 59, 0, 0, 60, 1, 1, 3, 2, 5, 3, 7, 4, 9, 5,
11, 6, 13, 7, 15, 8, 17, 9, 19, 10, 21, 11, 23, 12, 25, 13, 27, 14, 29,
15, 31, 16, 33, 17, 35, 18, 37, 19, 39, 20, 41, 21, 43, 22, 45, 23, 47,
24, 49, 25, 51, 26, 53, 27, 55, 28, 57, 29, 59, 30, 61, 31, 63, 32, 65,
33, 67, 34, 69, 35, 71, 0, 73, 0, 75, 0, 77, 0, 79, 0, 81, 0, 83, 0, 85,
0, 87, 0, 89, 0, 91, 0, 93, 0, 95, 0, 97, 0, 99, 0, 101, 0, 103, 0, 105,
0, 107, 0, 109, 0, 111, 0, 113, 0, 115, 0, 117, 36, 119, 37, 1, 0, 15,
3, 0, 76, 76, 85, 85, 117, 117, 4, 0, 10, 10, 13, 13, 34, 34, 92, 92, 3,
0, 65, 90, 95, 95, 97, 122, 1, 0, 48, 57, 2, 0, 66, 66, 98, 98, 1, 0, 48,
49, 2, 0, 88, 88, 120, 120, 1, 0, 49, 57, 1, 0, 48, 55, 3, 0, 48, 57, 65,
70, 97, 102, 2, 0, 69, 69, 101, 101, 2, 0, 43, 43, 45, 45, 2, 0, 80, 80,
112, 112, 10, 0, 34, 34, 39, 39, 63, 63, 92, 92, 97, 98, 102, 102, 110,
110, 114, 114, 116, 116, 118, 118, 2, 0, 9, 9, 32, 32, 465, 0, 1, 1, 0,
0, 0, 0, 3, 1, 0, 0, 0, 0, 5, 1, 0, 0, 0, 0, 7, 1, 0, 0, 0, 0, 9, 1, 0,
0, 0, 0, 11, 1, 0, 0, 0, 0, 13, 1, 0, 0, 0, 0, 15, 1, 0, 0, 0, 0, 17, 1,
0, 0, 0, 0, 19, 1, 0, 0, 0, 0, 21, 1, 0, 0, 0, 0, 23, 1, 0, 0, 0, 0, 25,
1, 0, 0, 0, 0, 27, 1, 0, 0, 0, 0, 29, 1, 0, 0, 0, 0, 31, 1, 0, 0, 0, 0,
33, 1, 0, 0, 0, 0, 35, 1, 0, 0, 0, 0, 37, 1, 0, 0, 0, 0, 39, 1, 0, 0, 0,
0, 41, 1, 0, 0, 0, 0, 43, 1, 0, 0, 0, 0, 45, 1, 0, 0, 0, 0, 47, 1, 0, 0,
0, 0, 49, 1, 0, 0, 0, 0, 51, 1, 0, 0, 0, 0, 53, 1, 0, 0, 0, 0, 55, 1, 0,
0, 0, 0, 57, 1, 0, 0, 0, 0, 59, 1, 0, 0, 0, 0, 61, 1, 0, 0, 0, 0, 63, 1,
0, 0, 0, 0, 65, 1, 0, 0, 0, 0, 67, 1, 0, 0, 0, 0, 69, 1, 0, 0, 0, 0, 117,
1, 0, 0, 0, 0, 119, 1, 0, 0, 0, 1, 121, 1, 0, 0, 0, 3, 123, 1, 0, 0, 0,
5, 125, 1, 0, 0, 0, 7, 127, 1, 0, 0, 0, 9, 129, 1, 0, 0, 0, 11, 131, 1,
0, 0, 0, 13, 133, 1, 0, 0, 0, 15, 136, 1, 0, 0, 0, 17, 138, 1, 0, 0, 0,
19, 141, 1, 0, 0, 0, 21, 144, 1, 0, 0, 0, 23, 155, 1, 0, 0, 0, 25, 157,
1, 0, 0, 0, 27, 159, 1, 0, 0, 0, 29, 161, 1, 0, 0, 0, 31, 163, 1, 0, 0,
0, 33, 165, 1, 0, 0, 0, 35, 167, 1, 0, 0, 0, 37, 170, 1, 0, 0, 0, 39, 173,
1, 0, 0, 0, 41, 176, 1, 0, 0, 0, 43, 178, 1, 0, 0, 0, 45, 180, 1, 0, 0,
0, 47, 187, 1, 0, 0, 0, 49, 193, 1, 0, 0, 0, 51, 195, 1, 0, 0, 0, 53, 201,
1, 0, 0, 0, 55, 203, 1, 0, 0, 0, 57, 206, 1, 0, 0, 0, 59, 213, 1, 0, 0,
0, 61, 250, 1, 0, 0, 0, 63, 256, 1, 0, 0, 0, 65, 260, 1, 0, 0, 0, 67, 262,
1, 0, 0, 0, 69, 271, 1, 0, 0, 0, 71, 282, 1, 0, 0, 0, 73, 285, 1, 0, 0,
0, 75, 296, 1, 0, 0, 0, 77, 298, 1, 0, 0, 0, 79, 300, 1, 0, 0, 0, 81, 302,
1, 0, 0, 0, 83, 309, 1, 0, 0, 0, 85, 316, 1, 0, 0, 0, 87, 323, 1, 0, 0,
0, 89, 327, 1, 0, 0, 0, 91, 329, 1, 0, 0, 0, 93, 331, 1, 0, 0, 0, 95, 333,
1, 0, 0, 0, 97, 348, 1, 0, 0, 0, 99, 357, 1, 0, 0, 0, 101, 359, 1, 0, 0,
0, 103, 375, 1, 0, 0, 0, 105, 377, 1, 0, 0, 0, 107, 384, 1, 0, 0, 0, 109,
396, 1, 0, 0, 0, 111, 399, 1, 0, 0, 0, 113, 403, 1, 0, 0, 0, 115, 424,
1, 0, 0, 0, 117, 427, 1, 0, 0, 0, 119, 438, 1, 0, 0, 0, 121, 122, 5, 40,
0, 0, 122, 2, 1, 0, 0, 0, 123, 124, 5, 41, 0, 0, 124, 4, 1, 0, 0, 0, 125,
126, 5, 91, 0, 0, 126, 6, 1, 0, 0, 0, 127, 128, 5, 44, 0, 0, 128, 8, 1,
0, 0, 0, 129, 130, 5, 93, 0, 0, 130, 10, 1, 0, 0, 0, 131, 132, 5, 60, 0,
0, 132, 12, 1, 0, 0, 0, 133, 134, 5, 60, 0, 0, 134, 135, 5, 61, 0, 0, 135,
14, 1, 0, 0, 0, 136, 137, 5, 62, 0, 0, 137, 16, 1, 0, 0, 0, 138, 139, 5,
62, 0, 0, 139, 140, 5, 61, 0, 0, 140, 18, 1, 0, 0, 0, 141, 142, 5, 61,
0, 0, 142, 143, 5, 61, 0, 0, 143, 20, 1, 0, 0, 0, 144, 145, 5, 33, 0, 0,
145, 146, 5, 61, 0, 0, 146, 22, 1, 0, 0, 0, 147, 148, 5, 108, 0, 0, 148,
149, 5, 105, 0, 0, 149, 150, 5, 107, 0, 0, 150, 156, 5, 101, 0, 0, 151,
152, 5, 76, 0, 0, 152, 153, 5, 73, 0, 0, 153, 154, 5, 75, 0, 0, 154, 156,
5, 69, 0, 0, 155, 147, 1, 0, 0, 0, 155, 151, 1, 0, 0, 0, 156, 24, 1, 0,
0, 0, 157, 158, 5, 43, 0, 0, 158, 26, 1, 0, 0, 0, 159, 160, 5, 45, 0, 0,
160, 28, 1, 0, 0, 0, 161, 162, 5, 42, 0, 0, 162, 30, 1, 0, 0, 0, 163, 164,
5, 47, 0, 0, 164, 32, 1, 0, 0, 0, 165, 166, 5, 37, 0, 0, 166, 34, 1, 0,
0, 0, 167, 168, 5, 42, 0, 0, 168, 169, 5, 42, 0, 0, 169, 36, 1, 0, 0, 0,
170, 171, 5, 60, 0, 0, 171, 172, 5, 60, 0, 0, 172, 38, 1, 0, 0, 0, 173,
174, 5, 62, 0, 0, 174, 175, 5, 62, 0, 0, 175, 40, 1, 0, 0, 0, 176, 177,
5, 38, 0, 0, 177, 42, 1, 0, 0, 0, 178, 179, 5, 124, 0, 0, 179, 44, 1, 0,
0, 0, 180, 181, 5, 94, 0, 0, 181, 46, 1, 0, 0, 0, 182, 183, 5, 38, 0, 0,
183, 188, 5, 38, 0, 0, 184, 185, 5, 97, 0, 0, 185, 186, 5, 110, 0, 0, 186,
188, 5, 100, 0, 0, 187, 182, 1, 0, 0, 0, 187, 184, 1, 0, 0, 0, 188, 48,
1, 0, 0, 0, 189, 190, 5, 124, 0, 0, 190, 194, 5, 124, 0, 0, 191, 192, 5,
111, 0, 0, 192, 194, 5, 114, 0, 0, 193, 189, 1, 0, 0, 0, 193, 191, 1, 0,
0, 0, 194, 50, 1, 0, 0, 0, 195, 196, 5, 126, 0, 0, 196, 52, 1, 0, 0, 0,
197, 202, 5, 33, 0, 0, 198, 199, 5, 110, 0, 0, 199, 200, 5, 111, 0, 0,
200, 202, 5, 116, 0, 0, 201, 197, 1, 0, 0, 0, 201, 198, 1, 0, 0, 0, 202,
54, 1, 0, 0, 0, 203, 204, 5, 105, 0, 0, 204, 205, 5, 110, 0, 0, 205, 56,
1, 0, 0, 0, 206, 207, 5, 110, 0, 0, 207, 208, 5, 111, 0, 0, 208, 209, 5,
116, 0, 0, 209, 210, 5, 32, 0, 0, 210, 211, 5, 105, 0, 0, 211, 212, 5,
110, 0, 0, 212, 58, 1, 0, 0, 0, 213, 218, 5, 91, 0, 0, 214, 217, 3, 117,
58, 0, 215, 217, 3, 119, 59, 0, 216, 214, 1, 0, 0, 0, 216, 215, 1, 0, 0,
0, 217, 220, 1, 0, 0, 0, 218, 216, 1, 0, 0, 0, 218, 219, 1, 0, 0, 0, 219,
221, 1, 0, 0, 0, 220, 218, 1, 0, 0, 0, 221, 222, 5, 93, 0, 0, 222, 60,
1, 0, 0, 0, 223, 224, 5, 116, 0, 0, 224, 225, 5, 114, 0, 0, 225, 226, 5,
117, 0, 0, 226, 251, 5, 101, 0, 0, 227, 228, 5, 84, 0, 0, 228, 229, 5,
114, 0, 0, 229, 230, 5, 117, 0, 0, 230, 251, 5, 101, 0, 0, 231, 232, 5,
84, 0, 0, 232, 233, 5, 82, 0, 0, 233, 234, 5, 85, 0, 0, 234, 251, 5, 69,
0, 0, 235, 236, 5, 102, 0, 0, 236, 237, 5, 97, 0, 0, 237, 238, 5, 108,
0, 0, 238, 239, 5, 115, 0, 0, 239, 251, 5, 101, 0, 0, 240, 241, 5, 70,
0, 0, 241, 242, 5, 97, 0, 0, 242, 243, 5, 108, 0, 0, 243, 244, 5, 115,
0, 0, 244, 251, 5, 101, 0, 0, 245, 246, 5, 70, 0, 0, 246, 247, 5, 65, 0,
0, 247, 248, 5, 76, 0, 0, 248, 249, 5, 83, 0, 0, 249, 251, 5, 69, 0, 0,
250, 223, 1, 0, 0, 0, 250, 227, 1, 0, 0, 0, 250, 231, 1, 0, 0, 0, 250,
235, 1, 0, 0, 0, 250, 240, 1, 0, 0, 0, 250, 245, 1, 0, 0, 0, 251, 62, 1,
0, 0, 0, 252, 257, 3, 83, 41, 0, 253, 257, 3, 85, 42, 0, 254, 257, 3, 87,
43, 0, 255, 257, 3, 81, 40, 0, 256, 252, 1, 0, 0, 0, 256, 253, 1, 0, 0,
0, 256, 254, 1, 0, 0, 0, 256, 255, 1, 0, 0, 0, 257, 64, 1, 0, 0, 0, 258,
261, 3, 99, 49, 0, 259, 261, 3, 101, 50, 0, 260, 258, 1, 0, 0, 0, 260,
259, 1, 0, 0, 0, 261, 66, 1, 0, 0, 0, 262, 267, 3, 77, 38, 0, 263, 266,
3, 77, 38, 0, 264, 266, 3, 79, 39, 0, 265, 263, 1, 0, 0, 0, 265, 264, 1,
0, 0, 0, 266, 269, 1, 0, 0, 0, 267, 265, 1, 0, 0, 0, 267, 268, 1, 0, 0,
0, 268, 68, 1, 0, 0, 0, 269, 267, 1, 0, 0, 0, 270, 272, 3, 71, 35, 0, 271,
270, 1, 0, 0, 0, 271, 272, 1, 0, 0, 0, 272, 273, 1, 0, 0, 0, 273, 275,
5, 34, 0, 0, 274, 276, 3, 73, 36, 0, 275, 274, 1, 0, 0, 0, 275, 276, 1,
0, 0, 0, 276, 277, 1, 0, 0, 0, 277, 278, 5, 34, 0, 0, 278, 70, 1, 0, 0,
0, 279, 280, 5, 117, 0, 0, 280, 283, 5, 56, 0, 0, 281, 283, 7, 0, 0, 0,
282, 279, 1, 0, 0, 0, 282, 281, 1, 0, 0, 0, 283, 72, 1, 0, 0, 0, 284, 286,
3, 75, 37, 0, 285, 284, 1, 0, 0, 0, 286, 287, 1, 0, 0, 0, 287, 285, 1,
0, 0, 0, 287, 288, 1, 0, 0, 0, 288, 74, 1, 0, 0, 0, 289, 297, 8, 1, 0,
0, 290, 297, 3, 115, 57, 0, 291, 292, 5, 92, 0, 0, 292, 297, 5, 10, 0,
0, 293, 294, 5, 92, 0, 0, 294, 295, 5, 13, 0, 0, 295, 297, 5, 10, 0, 0,
296, 289, 1, 0, 0, 0, 296, 290, 1, 0, 0, 0, 296, 291, 1, 0, 0, 0, 296,
293, 1, 0, 0, 0, 297, 76, 1, 0, 0, 0, 298, 299, 7, 2, 0, 0, 299, 78, 1,
0, 0, 0, 300, 301, 7, 3, 0, 0, 301, 80, 1, 0, 0, 0, 302, 303, 5, 48, 0,
0, 303, 305, 7, 4, 0, 0, 304, 306, 7, 5, 0, 0, 305, 304, 1, 0, 0, 0, 306,
307, 1, 0, 0, 0, 307, 305, 1, 0, 0, 0, 307, 308, 1, 0, 0, 0, 308, 82, 1,
0, 0, 0, 309, 313, 3, 89, 44, 0, 310, 312, 3, 79, 39, 0, 311, 310, 1, 0,
0, 0, 312, 315, 1, 0, 0, 0, 313, 311, 1, 0, 0, 0, 313, 314, 1, 0, 0, 0,
314, 84, 1, 0, 0, 0, 315, 313, 1, 0, 0, 0, 316, 320, 5, 48, 0, 0, 317,
319, 3, 91, 45, 0, 318, 317, 1, 0, 0, 0, 319, 322, 1, 0, 0, 0, 320, 318,
1, 0, 0, 0, 320, 321, 1, 0, 0, 0, 321, 86, 1, 0, 0, 0, 322, 320, 1, 0,
0, 0, 323, 324, 5, 48, 0, 0, 324, 325, 7, 6, 0, 0, 325, 326, 3, 111, 55,
0, 326, 88, 1, 0, 0, 0, 327, 328, 7, 7, 0, 0, 328, 90, 1, 0, 0, 0, 329,
330, 7, 8, 0, 0, 330, 92, 1, 0, 0, 0, 331, 332, 7, 9, 0, 0, 332, 94, 1,
0, 0, 0, 333, 334, 3, 93, 46, 0, 334, 335, 3, 93, 46, 0, 335, 336, 3, 93,
46, 0, 336, 337, 3, 93, 46, 0, 337, 96, 1, 0, 0, 0, 338, 339, 5, 92, 0,
0, 339, 340, 5, 117, 0, 0, 340, 341, 1, 0, 0, 0, 341, 349, 3, 95, 47, 0,
342, 343, 5, 92, 0, 0, 343, 344, 5, 85, 0, 0, 344, 345, 1, 0, 0, 0, 345,
346, 3, 95, 47, 0, 346, 347, 3, 95, 47, 0, 347, 349, 1, 0, 0, 0, 348, 338,
1, 0, 0, 0, 348, 342, 1, 0, 0, 0, 349, 98, 1, 0, 0, 0, 350, 352, 3, 103,
51, 0, 351, 353, 3, 105, 52, 0, 352, 351, 1, 0, 0, 0, 352, 353, 1, 0, 0,
0, 353, 358, 1, 0, 0, 0, 354, 355, 3, 107, 53, 0, 355, 356, 3, 105, 52,
0, 356, 358, 1, 0, 0, 0, 357, 350, 1, 0, 0, 0, 357, 354, 1, 0, 0, 0, 358,
100, 1, 0, 0, 0, 359, 360, 5, 48, 0, 0, 360, 363, 7, 6, 0, 0, 361, 364,
3, 109, 54, 0, 362, 364, 3, 111, 55, 0, 363, 361, 1, 0, 0, 0, 363, 362,
1, 0, 0, 0, 364, 365, 1, 0, 0, 0, 365, 366, 3, 113, 56, 0, 366, 102, 1,
0, 0, 0, 367, 369, 3, 107, 53, 0, 368, 367, 1, 0, 0, 0, 368, 369, 1, 0,
0, 0, 369, 370, 1, 0, 0, 0, 370, 371, 5, 46, 0, 0, 371, 376, 3, 107, 53,
0, 372, 373, 3, 107, 53, 0, 373, 374, 5, 46, 0, 0, 374, 376, 1, 0, 0, 0,
375, 368, 1, 0, 0, 0, 375, 372, 1, 0, 0, 0, 376, 104, 1, 0, 0, 0, 377,
379, 7, 10, 0, 0, 378, 380, 7, 11, 0, 0, 379, 378, 1, 0, 0, 0, 379, 380,
1, 0, 0, 0, 380, 381, 1, 0, 0, 0, 381, 382, 3, 107, 53, 0, 382, 106, 1,
0, 0, 0, 383, 385, 3, 79, 39, 0, 384, 383, 1, 0, 0, 0, 385, 386, 1, 0,
0, 0, 386, 384, 1, 0, 0, 0, 386, 387, 1, 0, 0, 0, 387, 108, 1, 0, 0, 0,
388, 390, 3, 111, 55, 0, 389, 388, 1, 0, 0, 0, 389, 390, 1, 0, 0, 0, 390,
391, 1, 0, 0, 0, 391, 392, 5, 46, 0, 0, 392, 397, 3, 111, 55, 0, 393, 394,
3, 111, 55, 0, 394, 395, 5, 46, 0, 0, 395, 397, 1, 0, 0, 0, 396, 389, 1,
0, 0, 0, 396, 393, 1, 0, 0, 0, 397, 110, 1, 0, 0, 0, 398, 400, 3, 93, 46,
0, 399, 398, 1, 0, 0, 0, 400, 401, 1, 0, 0, 0, 401, 399, 1, 0, 0, 0, 401,
402, 1, 0, 0, 0, 402, 112, 1, 0, 0, 0, 403, 405, 7, 12, 0, 0, 404, 406,
7, 11, 0, 0, 405, 404, 1, 0, 0, 0, 405, 406, 1, 0, 0, 0, 406, 407, 1, 0,
0, 0, 407, 408, 3, 107, 53, 0, 408, 114, 1, 0, 0, 0, 409, 410, 5, 92, 0,
0, 410, 425, 7, 13, 0, 0, 411, 412, 5, 92, 0, 0, 412, 414, 3, 91, 45, 0,
413, 415, 3, 91, 45, 0, 414, 413, 1, 0, 0, 0, 414, 415, 1, 0, 0, 0, 415,
417, 1, 0, 0, 0, 416, 418, 3, 91, 45, 0, 417, 416, 1, 0, 0, 0, 417, 418,
1, 0, 0, 0, 418, 425, 1, 0, 0, 0, 419, 420, 5, 92, 0, 0, 420, 421, 5, 120,
0, 0, 421, 422, 1, 0, 0, 0, 422, 425, 3, 111, 55, 0, 423, 425, 3, 97, 48,
0, 424, 409, 1, 0, 0, 0, 424, 411, 1, 0, 0, 0, 424, 419, 1, 0, 0, 0, 424,
423, 1, 0, 0, 0, 425, 116, 1, 0, 0, 0, 426, 428, 7, 14, 0, 0, 427, 426,
1, 0, 0, 0, 428, 429, 1, 0, 0, 0, 429, 427, 1, 0, 0, 0, 429, 430, 1, 0,
0, 0, 430, 431, 1, 0, 0, 0, 431, 432, 6, 58, 0, 0, 432, 118, 1, 0, 0, 0,
433, 435, 5, 13, 0, 0, 434, 436, 5, 10, 0, 0, 435, 434, 1, 0, 0, 0, 435,
436, 1, 0, 0, 0, 436, 439, 1, 0, 0, 0, 437, 439, 5, 10, 0, 0, 438, 433,
1, 0, 0, 0, 438, 437, 1, 0, 0, 0, 439, 440, 1, 0, 0, 0, 440, 441, 6, 59,
0, 0, 441, 120, 1, 0, 0, 0, 38, 0, 155, 187, 193, 201, 216, 218, 250, 256,
260, 265, 267, 271, 275, 282, 287, 296, 307, 313, 320, 348, 352, 357, 363,
368, 375, 379, 386, 389, 396, 401, 405, 414, 417, 424, 429, 435, 438, 1,
6, 0, 0,
}
deserializer := antlr.NewATNDeserializer(nil)
staticData.atn = deserializer.Deserialize(staticData.serializedATN)
atn := staticData.atn
staticData.decisionToDFA = make([]*antlr.DFA, len(atn.DecisionToState))
decisionToDFA := staticData.decisionToDFA
for index, state := range atn.DecisionToState {
decisionToDFA[index] = antlr.NewDFA(state, index)
}
}
// PlanLexerInit initializes any static state used to implement PlanLexer. By default the
// static state used to implement the lexer is lazily initialized during the first call to
// NewPlanLexer(). You can call this function if you wish to initialize the static state ahead
// of time.
func PlanLexerInit() {
staticData := &planlexerLexerStaticData
staticData.once.Do(planlexerLexerInit)
}
// NewPlanLexer produces a new lexer instance for the optional input antlr.CharStream.
func NewPlanLexer(input antlr.CharStream) *PlanLexer {
PlanLexerInit()
l := new(PlanLexer)
l.BaseLexer = antlr.NewBaseLexer(input)
staticData := &planlexerLexerStaticData
l.Interpreter = antlr.NewLexerATNSimulator(l, staticData.atn, staticData.decisionToDFA, staticData.predictionContextCache)
l.channelNames = staticData.channelNames
l.modeNames = staticData.modeNames
l.RuleNames = staticData.ruleNames
l.LiteralNames = staticData.literalNames
l.SymbolicNames = staticData.symbolicNames
l.GrammarFileName = "Plan.g4"
// TODO: l.EOF = antlr.TokenEOF

View File

@ -1,105 +1,125 @@
// Code generated from Plan.g4 by ANTLR 4.9. DO NOT EDIT.
// Code generated from java-escape by ANTLR 4.11.1. DO NOT EDIT.
package planparserv2 // Plan
import (
"fmt"
"reflect"
"strconv"
"sync"
"github.com/antlr/antlr4/runtime/Go/antlr"
"github.com/antlr/antlr4/runtime/Go/antlr/v4"
)
// Suppress unused import errors
var _ = fmt.Printf
var _ = reflect.Copy
var _ = strconv.Itoa
var parserATN = []uint16{
3, 24715, 42794, 33075, 47597, 16764, 15335, 30598, 22884, 3, 39, 89, 4,
2, 9, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3,
2, 3, 2, 5, 2, 17, 10, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3,
2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3,
2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3,
2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3,
2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 7, 2, 71, 10, 2, 12,
2, 14, 2, 74, 11, 2, 3, 2, 5, 2, 77, 10, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3,
2, 7, 2, 84, 10, 2, 12, 2, 14, 2, 87, 11, 2, 3, 2, 2, 3, 2, 3, 2, 2, 11,
4, 2, 15, 16, 28, 29, 3, 2, 17, 19, 3, 2, 15, 16, 3, 2, 21, 22, 3, 2, 8,
9, 3, 2, 10, 11, 3, 2, 8, 11, 3, 2, 12, 13, 3, 2, 30, 31, 2, 111, 2, 16,
3, 2, 2, 2, 4, 5, 8, 2, 1, 2, 5, 17, 7, 34, 2, 2, 6, 17, 7, 35, 2, 2, 7,
17, 7, 33, 2, 2, 8, 17, 7, 37, 2, 2, 9, 17, 7, 36, 2, 2, 10, 11, 7, 3,
2, 2, 11, 12, 5, 2, 2, 2, 12, 13, 7, 4, 2, 2, 13, 17, 3, 2, 2, 2, 14, 15,
9, 2, 2, 2, 15, 17, 5, 2, 2, 17, 16, 4, 3, 2, 2, 2, 16, 6, 3, 2, 2, 2,
16, 7, 3, 2, 2, 2, 16, 8, 3, 2, 2, 2, 16, 9, 3, 2, 2, 2, 16, 10, 3, 2,
2, 2, 16, 14, 3, 2, 2, 2, 17, 85, 3, 2, 2, 2, 18, 19, 12, 18, 2, 2, 19,
20, 7, 20, 2, 2, 20, 84, 5, 2, 2, 19, 21, 22, 12, 16, 2, 2, 22, 23, 9,
3, 2, 2, 23, 84, 5, 2, 2, 17, 24, 25, 12, 15, 2, 2, 25, 26, 9, 4, 2, 2,
26, 84, 5, 2, 2, 16, 27, 28, 12, 14, 2, 2, 28, 29, 9, 5, 2, 2, 29, 84,
5, 2, 2, 15, 30, 31, 12, 11, 2, 2, 31, 32, 9, 6, 2, 2, 32, 33, 7, 36, 2,
2, 33, 34, 9, 6, 2, 2, 34, 84, 5, 2, 2, 12, 35, 36, 12, 10, 2, 2, 36, 37,
9, 7, 2, 2, 37, 38, 7, 36, 2, 2, 38, 39, 9, 7, 2, 2, 39, 84, 5, 2, 2, 11,
40, 41, 12, 9, 2, 2, 41, 42, 9, 8, 2, 2, 42, 84, 5, 2, 2, 10, 43, 44, 12,
8, 2, 2, 44, 45, 9, 9, 2, 2, 45, 84, 5, 2, 2, 9, 46, 47, 12, 7, 2, 2, 47,
48, 7, 23, 2, 2, 48, 84, 5, 2, 2, 8, 49, 50, 12, 6, 2, 2, 50, 51, 7, 25,
2, 2, 51, 84, 5, 2, 2, 7, 52, 53, 12, 5, 2, 2, 53, 54, 7, 24, 2, 2, 54,
84, 5, 2, 2, 6, 55, 56, 12, 4, 2, 2, 56, 57, 7, 26, 2, 2, 57, 84, 5, 2,
2, 5, 58, 59, 12, 3, 2, 2, 59, 60, 7, 27, 2, 2, 60, 84, 5, 2, 2, 4, 61,
62, 12, 19, 2, 2, 62, 63, 7, 14, 2, 2, 63, 84, 7, 37, 2, 2, 64, 65, 12,
13, 2, 2, 65, 66, 9, 10, 2, 2, 66, 67, 7, 5, 2, 2, 67, 72, 5, 2, 2, 2,
68, 69, 7, 6, 2, 2, 69, 71, 5, 2, 2, 2, 70, 68, 3, 2, 2, 2, 71, 74, 3,
2, 2, 2, 72, 70, 3, 2, 2, 2, 72, 73, 3, 2, 2, 2, 73, 76, 3, 2, 2, 2, 74,
72, 3, 2, 2, 2, 75, 77, 7, 6, 2, 2, 76, 75, 3, 2, 2, 2, 76, 77, 3, 2, 2,
2, 77, 78, 3, 2, 2, 2, 78, 79, 7, 7, 2, 2, 79, 84, 3, 2, 2, 2, 80, 81,
12, 12, 2, 2, 81, 82, 9, 10, 2, 2, 82, 84, 7, 32, 2, 2, 83, 18, 3, 2, 2,
2, 83, 21, 3, 2, 2, 2, 83, 24, 3, 2, 2, 2, 83, 27, 3, 2, 2, 2, 83, 30,
3, 2, 2, 2, 83, 35, 3, 2, 2, 2, 83, 40, 3, 2, 2, 2, 83, 43, 3, 2, 2, 2,
83, 46, 3, 2, 2, 2, 83, 49, 3, 2, 2, 2, 83, 52, 3, 2, 2, 2, 83, 55, 3,
2, 2, 2, 83, 58, 3, 2, 2, 2, 83, 61, 3, 2, 2, 2, 83, 64, 3, 2, 2, 2, 83,
80, 3, 2, 2, 2, 84, 87, 3, 2, 2, 2, 85, 83, 3, 2, 2, 2, 85, 86, 3, 2, 2,
2, 86, 3, 3, 2, 2, 2, 87, 85, 3, 2, 2, 2, 7, 16, 72, 76, 83, 85,
}
var literalNames = []string{
"", "'('", "')'", "'['", "','", "']'", "'<'", "'<='", "'>'", "'>='", "'=='",
"'!='", "", "'+'", "'-'", "'*'", "'/'", "'%'", "'**'", "'<<'", "'>>'",
"'&'", "'|'", "'^'", "", "", "'~'", "", "'in'", "'not in'",
}
var symbolicNames = []string{
"", "", "", "", "", "", "LT", "LE", "GT", "GE", "EQ", "NE", "LIKE", "ADD",
"SUB", "MUL", "DIV", "MOD", "POW", "SHL", "SHR", "BAND", "BOR", "BXOR",
"AND", "OR", "BNOT", "NOT", "IN", "NIN", "EmptyTerm", "BooleanConstant",
"IntegerConstant", "FloatingConstant", "Identifier", "StringLiteral", "Whitespace",
"Newline",
}
var ruleNames = []string{
"expr",
}
var _ = sync.Once{}
type PlanParser struct {
*antlr.BaseParser
}
// NewPlanParser produces a new parser instance for the optional input antlr.TokenStream.
//
// The *PlanParser instance produced may be reused by calling the SetInputStream method.
// The initial parser configuration is expensive to construct, and the object is not thread-safe;
// however, if used within a Golang sync.Pool, the construction cost amortizes well and the
// objects can be used in a thread-safe manner.
func NewPlanParser(input antlr.TokenStream) *PlanParser {
this := new(PlanParser)
deserializer := antlr.NewATNDeserializer(nil)
deserializedATN := deserializer.DeserializeFromUInt16(parserATN)
decisionToDFA := make([]*antlr.DFA, len(deserializedATN.DecisionToState))
for index, ds := range deserializedATN.DecisionToState {
decisionToDFA[index] = antlr.NewDFA(ds, index)
}
this.BaseParser = antlr.NewBaseParser(input)
var planParserStaticData struct {
once sync.Once
serializedATN []int32
literalNames []string
symbolicNames []string
ruleNames []string
predictionContextCache *antlr.PredictionContextCache
atn *antlr.ATN
decisionToDFA []*antlr.DFA
}
this.Interpreter = antlr.NewParserATNSimulator(this, deserializedATN, decisionToDFA, antlr.NewPredictionContextCache())
this.RuleNames = ruleNames
this.LiteralNames = literalNames
this.SymbolicNames = symbolicNames
this.GrammarFileName = "Plan.g4"
func planParserInit() {
staticData := &planParserStaticData
staticData.literalNames = []string{
"", "'('", "')'", "'['", "','", "']'", "'<'", "'<='", "'>'", "'>='",
"'=='", "'!='", "", "'+'", "'-'", "'*'", "'/'", "'%'", "'**'", "'<<'",
"'>>'", "'&'", "'|'", "'^'", "", "", "'~'", "", "'in'", "'not in'",
}
staticData.symbolicNames = []string{
"", "", "", "", "", "", "LT", "LE", "GT", "GE", "EQ", "NE", "LIKE",
"ADD", "SUB", "MUL", "DIV", "MOD", "POW", "SHL", "SHR", "BAND", "BOR",
"BXOR", "AND", "OR", "BNOT", "NOT", "IN", "NIN", "EmptyTerm", "BooleanConstant",
"IntegerConstant", "FloatingConstant", "Identifier", "StringLiteral",
"Whitespace", "Newline",
}
staticData.ruleNames = []string{
"expr",
}
staticData.predictionContextCache = antlr.NewPredictionContextCache()
staticData.serializedATN = []int32{
4, 1, 37, 87, 2, 0, 7, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1,
0, 1, 0, 1, 0, 1, 0, 1, 0, 3, 0, 15, 8, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0,
1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0,
1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0,
1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0,
1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 5, 0,
69, 8, 0, 10, 0, 12, 0, 72, 9, 0, 1, 0, 3, 0, 75, 8, 0, 1, 0, 1, 0, 1,
0, 1, 0, 1, 0, 5, 0, 82, 8, 0, 10, 0, 12, 0, 85, 9, 0, 1, 0, 0, 1, 0, 1,
0, 0, 9, 2, 0, 13, 14, 26, 27, 1, 0, 15, 17, 1, 0, 13, 14, 1, 0, 19, 20,
1, 0, 6, 7, 1, 0, 8, 9, 1, 0, 6, 9, 1, 0, 10, 11, 1, 0, 28, 29, 109, 0,
14, 1, 0, 0, 0, 2, 3, 6, 0, -1, 0, 3, 15, 5, 32, 0, 0, 4, 15, 5, 33, 0,
0, 5, 15, 5, 31, 0, 0, 6, 15, 5, 35, 0, 0, 7, 15, 5, 34, 0, 0, 8, 9, 5,
1, 0, 0, 9, 10, 3, 0, 0, 0, 10, 11, 5, 2, 0, 0, 11, 15, 1, 0, 0, 0, 12,
13, 7, 0, 0, 0, 13, 15, 3, 0, 0, 15, 14, 2, 1, 0, 0, 0, 14, 4, 1, 0, 0,
0, 14, 5, 1, 0, 0, 0, 14, 6, 1, 0, 0, 0, 14, 7, 1, 0, 0, 0, 14, 8, 1, 0,
0, 0, 14, 12, 1, 0, 0, 0, 15, 83, 1, 0, 0, 0, 16, 17, 10, 16, 0, 0, 17,
18, 5, 18, 0, 0, 18, 82, 3, 0, 0, 17, 19, 20, 10, 14, 0, 0, 20, 21, 7,
1, 0, 0, 21, 82, 3, 0, 0, 15, 22, 23, 10, 13, 0, 0, 23, 24, 7, 2, 0, 0,
24, 82, 3, 0, 0, 14, 25, 26, 10, 12, 0, 0, 26, 27, 7, 3, 0, 0, 27, 82,
3, 0, 0, 13, 28, 29, 10, 9, 0, 0, 29, 30, 7, 4, 0, 0, 30, 31, 5, 34, 0,
0, 31, 32, 7, 4, 0, 0, 32, 82, 3, 0, 0, 10, 33, 34, 10, 8, 0, 0, 34, 35,
7, 5, 0, 0, 35, 36, 5, 34, 0, 0, 36, 37, 7, 5, 0, 0, 37, 82, 3, 0, 0, 9,
38, 39, 10, 7, 0, 0, 39, 40, 7, 6, 0, 0, 40, 82, 3, 0, 0, 8, 41, 42, 10,
6, 0, 0, 42, 43, 7, 7, 0, 0, 43, 82, 3, 0, 0, 7, 44, 45, 10, 5, 0, 0, 45,
46, 5, 21, 0, 0, 46, 82, 3, 0, 0, 6, 47, 48, 10, 4, 0, 0, 48, 49, 5, 23,
0, 0, 49, 82, 3, 0, 0, 5, 50, 51, 10, 3, 0, 0, 51, 52, 5, 22, 0, 0, 52,
82, 3, 0, 0, 4, 53, 54, 10, 2, 0, 0, 54, 55, 5, 24, 0, 0, 55, 82, 3, 0,
0, 3, 56, 57, 10, 1, 0, 0, 57, 58, 5, 25, 0, 0, 58, 82, 3, 0, 0, 2, 59,
60, 10, 17, 0, 0, 60, 61, 5, 12, 0, 0, 61, 82, 5, 35, 0, 0, 62, 63, 10,
11, 0, 0, 63, 64, 7, 8, 0, 0, 64, 65, 5, 3, 0, 0, 65, 70, 3, 0, 0, 0, 66,
67, 5, 4, 0, 0, 67, 69, 3, 0, 0, 0, 68, 66, 1, 0, 0, 0, 69, 72, 1, 0, 0,
0, 70, 68, 1, 0, 0, 0, 70, 71, 1, 0, 0, 0, 71, 74, 1, 0, 0, 0, 72, 70,
1, 0, 0, 0, 73, 75, 5, 4, 0, 0, 74, 73, 1, 0, 0, 0, 74, 75, 1, 0, 0, 0,
75, 76, 1, 0, 0, 0, 76, 77, 5, 5, 0, 0, 77, 82, 1, 0, 0, 0, 78, 79, 10,
10, 0, 0, 79, 80, 7, 8, 0, 0, 80, 82, 5, 30, 0, 0, 81, 16, 1, 0, 0, 0,
81, 19, 1, 0, 0, 0, 81, 22, 1, 0, 0, 0, 81, 25, 1, 0, 0, 0, 81, 28, 1,
0, 0, 0, 81, 33, 1, 0, 0, 0, 81, 38, 1, 0, 0, 0, 81, 41, 1, 0, 0, 0, 81,
44, 1, 0, 0, 0, 81, 47, 1, 0, 0, 0, 81, 50, 1, 0, 0, 0, 81, 53, 1, 0, 0,
0, 81, 56, 1, 0, 0, 0, 81, 59, 1, 0, 0, 0, 81, 62, 1, 0, 0, 0, 81, 78,
1, 0, 0, 0, 82, 85, 1, 0, 0, 0, 83, 81, 1, 0, 0, 0, 83, 84, 1, 0, 0, 0,
84, 1, 1, 0, 0, 0, 85, 83, 1, 0, 0, 0, 5, 14, 70, 74, 81, 83,
}
deserializer := antlr.NewATNDeserializer(nil)
staticData.atn = deserializer.Deserialize(staticData.serializedATN)
atn := staticData.atn
staticData.decisionToDFA = make([]*antlr.DFA, len(atn.DecisionToState))
decisionToDFA := staticData.decisionToDFA
for index, state := range atn.DecisionToState {
decisionToDFA[index] = antlr.NewDFA(state, index)
}
}
// PlanParserInit initializes any static state used to implement PlanParser. By default the
// static state used to implement the parser is lazily initialized during the first call to
// NewPlanParser(). You can call this function if you wish to initialize the static state ahead
// of time.
func PlanParserInit() {
staticData := &planParserStaticData
staticData.once.Do(planParserInit)
}
// NewPlanParser produces a new parser instance for the optional input antlr.TokenStream.
func NewPlanParser(input antlr.TokenStream) *PlanParser {
PlanParserInit()
this := new(PlanParser)
this.BaseParser = antlr.NewBaseParser(input)
staticData := &planParserStaticData
this.Interpreter = antlr.NewParserATNSimulator(this, staticData.atn, staticData.decisionToDFA, staticData.predictionContextCache)
this.RuleNames = staticData.ruleNames
this.LiteralNames = staticData.literalNames
this.SymbolicNames = staticData.symbolicNames
this.GrammarFileName = "java-escape"
return this
}
@ -223,12 +243,20 @@ func (s *ShiftContext) GetRuleContext() antlr.RuleContext {
}
func (s *ShiftContext) AllExpr() []IExprContext {
var ts = s.GetTypedRuleContexts(reflect.TypeOf((*IExprContext)(nil)).Elem())
var tst = make([]IExprContext, len(ts))
children := s.GetChildren()
len := 0
for _, ctx := range children {
if _, ok := ctx.(IExprContext); ok {
len++
}
}
for i, t := range ts {
if t != nil {
tst := make([]IExprContext, len)
i := 0
for _, ctx := range children {
if t, ok := ctx.(IExprContext); ok {
tst[i] = t.(IExprContext)
i++
}
}
@ -236,7 +264,17 @@ func (s *ShiftContext) AllExpr() []IExprContext {
}
func (s *ShiftContext) Expr(i int) IExprContext {
var t = s.GetTypedRuleContext(reflect.TypeOf((*IExprContext)(nil)).Elem(), i)
var t antlr.RuleContext
j := 0
for _, ctx := range s.GetChildren() {
if _, ok := ctx.(IExprContext); ok {
if j == i {
t = ctx.(antlr.RuleContext)
break
}
j++
}
}
if t == nil {
return nil
@ -292,12 +330,20 @@ func (s *ReverseRangeContext) GetRuleContext() antlr.RuleContext {
}
func (s *ReverseRangeContext) AllExpr() []IExprContext {
var ts = s.GetTypedRuleContexts(reflect.TypeOf((*IExprContext)(nil)).Elem())
var tst = make([]IExprContext, len(ts))
children := s.GetChildren()
len := 0
for _, ctx := range children {
if _, ok := ctx.(IExprContext); ok {
len++
}
}
for i, t := range ts {
if t != nil {
tst := make([]IExprContext, len)
i := 0
for _, ctx := range children {
if t, ok := ctx.(IExprContext); ok {
tst[i] = t.(IExprContext)
i++
}
}
@ -305,7 +351,17 @@ func (s *ReverseRangeContext) AllExpr() []IExprContext {
}
func (s *ReverseRangeContext) Expr(i int) IExprContext {
var t = s.GetTypedRuleContext(reflect.TypeOf((*IExprContext)(nil)).Elem(), i)
var t antlr.RuleContext
j := 0
for _, ctx := range s.GetChildren() {
if _, ok := ctx.(IExprContext); ok {
if j == i {
t = ctx.(antlr.RuleContext)
break
}
j++
}
}
if t == nil {
return nil
@ -363,12 +419,20 @@ func (s *BitOrContext) GetRuleContext() antlr.RuleContext {
}
func (s *BitOrContext) AllExpr() []IExprContext {
var ts = s.GetTypedRuleContexts(reflect.TypeOf((*IExprContext)(nil)).Elem())
var tst = make([]IExprContext, len(ts))
children := s.GetChildren()
len := 0
for _, ctx := range children {
if _, ok := ctx.(IExprContext); ok {
len++
}
}
for i, t := range ts {
if t != nil {
tst := make([]IExprContext, len)
i := 0
for _, ctx := range children {
if t, ok := ctx.(IExprContext); ok {
tst[i] = t.(IExprContext)
i++
}
}
@ -376,7 +440,17 @@ func (s *BitOrContext) AllExpr() []IExprContext {
}
func (s *BitOrContext) Expr(i int) IExprContext {
var t = s.GetTypedRuleContext(reflect.TypeOf((*IExprContext)(nil)).Elem(), i)
var t antlr.RuleContext
j := 0
for _, ctx := range s.GetChildren() {
if _, ok := ctx.(IExprContext); ok {
if j == i {
t = ctx.(antlr.RuleContext)
break
}
j++
}
}
if t == nil {
return nil
@ -423,12 +497,20 @@ func (s *AddSubContext) GetRuleContext() antlr.RuleContext {
}
func (s *AddSubContext) AllExpr() []IExprContext {
var ts = s.GetTypedRuleContexts(reflect.TypeOf((*IExprContext)(nil)).Elem())
var tst = make([]IExprContext, len(ts))
children := s.GetChildren()
len := 0
for _, ctx := range children {
if _, ok := ctx.(IExprContext); ok {
len++
}
}
for i, t := range ts {
if t != nil {
tst := make([]IExprContext, len)
i := 0
for _, ctx := range children {
if t, ok := ctx.(IExprContext); ok {
tst[i] = t.(IExprContext)
i++
}
}
@ -436,7 +518,17 @@ func (s *AddSubContext) AllExpr() []IExprContext {
}
func (s *AddSubContext) Expr(i int) IExprContext {
var t = s.GetTypedRuleContext(reflect.TypeOf((*IExprContext)(nil)).Elem(), i)
var t antlr.RuleContext
j := 0
for _, ctx := range s.GetChildren() {
if _, ok := ctx.(IExprContext); ok {
if j == i {
t = ctx.(antlr.RuleContext)
break
}
j++
}
}
if t == nil {
return nil
@ -482,7 +574,13 @@ func (s *ParensContext) GetRuleContext() antlr.RuleContext {
}
func (s *ParensContext) Expr() IExprContext {
var t = s.GetTypedRuleContext(reflect.TypeOf((*IExprContext)(nil)).Elem(), 0)
var t antlr.RuleContext
for _, ctx := range s.GetChildren() {
if _, ok := ctx.(IExprContext); ok {
t = ctx.(antlr.RuleContext)
break
}
}
if t == nil {
return nil
@ -525,12 +623,20 @@ func (s *RelationalContext) GetRuleContext() antlr.RuleContext {
}
func (s *RelationalContext) AllExpr() []IExprContext {
var ts = s.GetTypedRuleContexts(reflect.TypeOf((*IExprContext)(nil)).Elem())
var tst = make([]IExprContext, len(ts))
children := s.GetChildren()
len := 0
for _, ctx := range children {
if _, ok := ctx.(IExprContext); ok {
len++
}
}
for i, t := range ts {
if t != nil {
tst := make([]IExprContext, len)
i := 0
for _, ctx := range children {
if t, ok := ctx.(IExprContext); ok {
tst[i] = t.(IExprContext)
i++
}
}
@ -538,7 +644,17 @@ func (s *RelationalContext) AllExpr() []IExprContext {
}
func (s *RelationalContext) Expr(i int) IExprContext {
var t = s.GetTypedRuleContext(reflect.TypeOf((*IExprContext)(nil)).Elem(), i)
var t antlr.RuleContext
j := 0
for _, ctx := range s.GetChildren() {
if _, ok := ctx.(IExprContext); ok {
if j == i {
t = ctx.(antlr.RuleContext)
break
}
j++
}
}
if t == nil {
return nil
@ -629,12 +745,20 @@ func (s *TermContext) GetRuleContext() antlr.RuleContext {
}
func (s *TermContext) AllExpr() []IExprContext {
var ts = s.GetTypedRuleContexts(reflect.TypeOf((*IExprContext)(nil)).Elem())
var tst = make([]IExprContext, len(ts))
children := s.GetChildren()
len := 0
for _, ctx := range children {
if _, ok := ctx.(IExprContext); ok {
len++
}
}
for i, t := range ts {
if t != nil {
tst := make([]IExprContext, len)
i := 0
for _, ctx := range children {
if t, ok := ctx.(IExprContext); ok {
tst[i] = t.(IExprContext)
i++
}
}
@ -642,7 +766,17 @@ func (s *TermContext) AllExpr() []IExprContext {
}
func (s *TermContext) Expr(i int) IExprContext {
var t = s.GetTypedRuleContext(reflect.TypeOf((*IExprContext)(nil)).Elem(), i)
var t antlr.RuleContext
j := 0
for _, ctx := range s.GetChildren() {
if _, ok := ctx.(IExprContext); ok {
if j == i {
t = ctx.(antlr.RuleContext)
break
}
j++
}
}
if t == nil {
return nil
@ -730,12 +864,20 @@ func (s *RangeContext) GetRuleContext() antlr.RuleContext {
}
func (s *RangeContext) AllExpr() []IExprContext {
var ts = s.GetTypedRuleContexts(reflect.TypeOf((*IExprContext)(nil)).Elem())
var tst = make([]IExprContext, len(ts))
children := s.GetChildren()
len := 0
for _, ctx := range children {
if _, ok := ctx.(IExprContext); ok {
len++
}
}
for i, t := range ts {
if t != nil {
tst := make([]IExprContext, len)
i := 0
for _, ctx := range children {
if t, ok := ctx.(IExprContext); ok {
tst[i] = t.(IExprContext)
i++
}
}
@ -743,7 +885,17 @@ func (s *RangeContext) AllExpr() []IExprContext {
}
func (s *RangeContext) Expr(i int) IExprContext {
var t = s.GetTypedRuleContext(reflect.TypeOf((*IExprContext)(nil)).Elem(), i)
var t antlr.RuleContext
j := 0
for _, ctx := range s.GetChildren() {
if _, ok := ctx.(IExprContext); ok {
if j == i {
t = ctx.(antlr.RuleContext)
break
}
j++
}
}
if t == nil {
return nil
@ -806,7 +958,13 @@ func (s *UnaryContext) GetRuleContext() antlr.RuleContext {
}
func (s *UnaryContext) Expr() IExprContext {
var t = s.GetTypedRuleContext(reflect.TypeOf((*IExprContext)(nil)).Elem(), 0)
var t antlr.RuleContext
for _, ctx := range s.GetChildren() {
if _, ok := ctx.(IExprContext); ok {
t = ctx.(antlr.RuleContext)
break
}
}
if t == nil {
return nil
@ -860,12 +1018,20 @@ func (s *LogicalOrContext) GetRuleContext() antlr.RuleContext {
}
func (s *LogicalOrContext) AllExpr() []IExprContext {
var ts = s.GetTypedRuleContexts(reflect.TypeOf((*IExprContext)(nil)).Elem())
var tst = make([]IExprContext, len(ts))
children := s.GetChildren()
len := 0
for _, ctx := range children {
if _, ok := ctx.(IExprContext); ok {
len++
}
}
for i, t := range ts {
if t != nil {
tst := make([]IExprContext, len)
i := 0
for _, ctx := range children {
if t, ok := ctx.(IExprContext); ok {
tst[i] = t.(IExprContext)
i++
}
}
@ -873,7 +1039,17 @@ func (s *LogicalOrContext) AllExpr() []IExprContext {
}
func (s *LogicalOrContext) Expr(i int) IExprContext {
var t = s.GetTypedRuleContext(reflect.TypeOf((*IExprContext)(nil)).Elem(), i)
var t antlr.RuleContext
j := 0
for _, ctx := range s.GetChildren() {
if _, ok := ctx.(IExprContext); ok {
if j == i {
t = ctx.(antlr.RuleContext)
break
}
j++
}
}
if t == nil {
return nil
@ -952,12 +1128,20 @@ func (s *MulDivModContext) GetRuleContext() antlr.RuleContext {
}
func (s *MulDivModContext) AllExpr() []IExprContext {
var ts = s.GetTypedRuleContexts(reflect.TypeOf((*IExprContext)(nil)).Elem())
var tst = make([]IExprContext, len(ts))
children := s.GetChildren()
len := 0
for _, ctx := range children {
if _, ok := ctx.(IExprContext); ok {
len++
}
}
for i, t := range ts {
if t != nil {
tst := make([]IExprContext, len)
i := 0
for _, ctx := range children {
if t, ok := ctx.(IExprContext); ok {
tst[i] = t.(IExprContext)
i++
}
}
@ -965,7 +1149,17 @@ func (s *MulDivModContext) AllExpr() []IExprContext {
}
func (s *MulDivModContext) Expr(i int) IExprContext {
var t = s.GetTypedRuleContext(reflect.TypeOf((*IExprContext)(nil)).Elem(), i)
var t antlr.RuleContext
j := 0
for _, ctx := range s.GetChildren() {
if _, ok := ctx.(IExprContext); ok {
if j == i {
t = ctx.(antlr.RuleContext)
break
}
j++
}
}
if t == nil {
return nil
@ -1047,12 +1241,20 @@ func (s *BitXorContext) GetRuleContext() antlr.RuleContext {
}
func (s *BitXorContext) AllExpr() []IExprContext {
var ts = s.GetTypedRuleContexts(reflect.TypeOf((*IExprContext)(nil)).Elem())
var tst = make([]IExprContext, len(ts))
children := s.GetChildren()
len := 0
for _, ctx := range children {
if _, ok := ctx.(IExprContext); ok {
len++
}
}
for i, t := range ts {
if t != nil {
tst := make([]IExprContext, len)
i := 0
for _, ctx := range children {
if t, ok := ctx.(IExprContext); ok {
tst[i] = t.(IExprContext)
i++
}
}
@ -1060,7 +1262,17 @@ func (s *BitXorContext) AllExpr() []IExprContext {
}
func (s *BitXorContext) Expr(i int) IExprContext {
var t = s.GetTypedRuleContext(reflect.TypeOf((*IExprContext)(nil)).Elem(), i)
var t antlr.RuleContext
j := 0
for _, ctx := range s.GetChildren() {
if _, ok := ctx.(IExprContext); ok {
if j == i {
t = ctx.(antlr.RuleContext)
break
}
j++
}
}
if t == nil {
return nil
@ -1102,7 +1314,13 @@ func (s *LikeContext) GetRuleContext() antlr.RuleContext {
}
func (s *LikeContext) Expr() IExprContext {
var t = s.GetTypedRuleContext(reflect.TypeOf((*IExprContext)(nil)).Elem(), 0)
var t antlr.RuleContext
for _, ctx := range s.GetChildren() {
if _, ok := ctx.(IExprContext); ok {
t = ctx.(antlr.RuleContext)
break
}
}
if t == nil {
return nil
@ -1148,12 +1366,20 @@ func (s *BitAndContext) GetRuleContext() antlr.RuleContext {
}
func (s *BitAndContext) AllExpr() []IExprContext {
var ts = s.GetTypedRuleContexts(reflect.TypeOf((*IExprContext)(nil)).Elem())
var tst = make([]IExprContext, len(ts))
children := s.GetChildren()
len := 0
for _, ctx := range children {
if _, ok := ctx.(IExprContext); ok {
len++
}
}
for i, t := range ts {
if t != nil {
tst := make([]IExprContext, len)
i := 0
for _, ctx := range children {
if t, ok := ctx.(IExprContext); ok {
tst[i] = t.(IExprContext)
i++
}
}
@ -1161,7 +1387,17 @@ func (s *BitAndContext) AllExpr() []IExprContext {
}
func (s *BitAndContext) Expr(i int) IExprContext {
var t = s.GetTypedRuleContext(reflect.TypeOf((*IExprContext)(nil)).Elem(), i)
var t antlr.RuleContext
j := 0
for _, ctx := range s.GetChildren() {
if _, ok := ctx.(IExprContext); ok {
if j == i {
t = ctx.(antlr.RuleContext)
break
}
j++
}
}
if t == nil {
return nil
@ -1203,12 +1439,20 @@ func (s *LogicalAndContext) GetRuleContext() antlr.RuleContext {
}
func (s *LogicalAndContext) AllExpr() []IExprContext {
var ts = s.GetTypedRuleContexts(reflect.TypeOf((*IExprContext)(nil)).Elem())
var tst = make([]IExprContext, len(ts))
children := s.GetChildren()
len := 0
for _, ctx := range children {
if _, ok := ctx.(IExprContext); ok {
len++
}
}
for i, t := range ts {
if t != nil {
tst := make([]IExprContext, len)
i := 0
for _, ctx := range children {
if t, ok := ctx.(IExprContext); ok {
tst[i] = t.(IExprContext)
i++
}
}
@ -1216,7 +1460,17 @@ func (s *LogicalAndContext) AllExpr() []IExprContext {
}
func (s *LogicalAndContext) Expr(i int) IExprContext {
var t = s.GetTypedRuleContext(reflect.TypeOf((*IExprContext)(nil)).Elem(), i)
var t antlr.RuleContext
j := 0
for _, ctx := range s.GetChildren() {
if _, ok := ctx.(IExprContext); ok {
if j == i {
t = ctx.(antlr.RuleContext)
break
}
j++
}
}
if t == nil {
return nil
@ -1263,7 +1517,13 @@ func (s *EmptyTermContext) GetRuleContext() antlr.RuleContext {
}
func (s *EmptyTermContext) Expr() IExprContext {
var t = s.GetTypedRuleContext(reflect.TypeOf((*IExprContext)(nil)).Elem(), 0)
var t antlr.RuleContext
for _, ctx := range s.GetChildren() {
if _, ok := ctx.(IExprContext); ok {
t = ctx.(antlr.RuleContext)
break
}
}
if t == nil {
return nil
@ -1318,12 +1578,20 @@ func (s *EqualityContext) GetRuleContext() antlr.RuleContext {
}
func (s *EqualityContext) AllExpr() []IExprContext {
var ts = s.GetTypedRuleContexts(reflect.TypeOf((*IExprContext)(nil)).Elem())
var tst = make([]IExprContext, len(ts))
children := s.GetChildren()
len := 0
for _, ctx := range children {
if _, ok := ctx.(IExprContext); ok {
len++
}
}
for i, t := range ts {
if t != nil {
tst := make([]IExprContext, len)
i := 0
for _, ctx := range children {
if t, ok := ctx.(IExprContext); ok {
tst[i] = t.(IExprContext)
i++
}
}
@ -1331,7 +1599,17 @@ func (s *EqualityContext) AllExpr() []IExprContext {
}
func (s *EqualityContext) Expr(i int) IExprContext {
var t = s.GetTypedRuleContext(reflect.TypeOf((*IExprContext)(nil)).Elem(), i)
var t antlr.RuleContext
j := 0
for _, ctx := range s.GetChildren() {
if _, ok := ctx.(IExprContext); ok {
if j == i {
t = ctx.(antlr.RuleContext)
break
}
j++
}
}
if t == nil {
return nil
@ -1409,12 +1687,20 @@ func (s *PowerContext) GetRuleContext() antlr.RuleContext {
}
func (s *PowerContext) AllExpr() []IExprContext {
var ts = s.GetTypedRuleContexts(reflect.TypeOf((*IExprContext)(nil)).Elem())
var tst = make([]IExprContext, len(ts))
children := s.GetChildren()
len := 0
for _, ctx := range children {
if _, ok := ctx.(IExprContext); ok {
len++
}
}
for i, t := range ts {
if t != nil {
tst := make([]IExprContext, len)
i := 0
for _, ctx := range children {
if t, ok := ctx.(IExprContext); ok {
tst[i] = t.(IExprContext)
i++
}
}
@ -1422,7 +1708,17 @@ func (s *PowerContext) AllExpr() []IExprContext {
}
func (s *PowerContext) Expr(i int) IExprContext {
var t = s.GetTypedRuleContext(reflect.TypeOf((*IExprContext)(nil)).Elem(), i)
var t antlr.RuleContext
j := 0
for _, ctx := range s.GetChildren() {
if _, ok := ctx.(IExprContext); ok {
if j == i {
t = ctx.(antlr.RuleContext)
break
}
j++
}
}
if t == nil {
return nil
@ -1450,6 +1746,9 @@ func (p *PlanParser) Expr() (localctx IExprContext) {
}
func (p *PlanParser) expr(_p int) (localctx IExprContext) {
this := p
_ = this
var _parentctx antlr.ParserRuleContext = p.GetParserRuleContext()
_parentState := p.GetState()
localctx = NewExprContext(p, p.GetParserRuleContext(), _parentState)
@ -1558,7 +1857,7 @@ func (p *PlanParser) expr(_p int) (localctx IExprContext) {
_la = p.GetTokenStream().LA(1)
if !(((_la)&-(0x1f+1)) == 0 && ((1<<uint(_la))&((1<<PlanParserADD)|(1<<PlanParserSUB)|(1<<PlanParserBNOT)|(1<<PlanParserNOT))) != 0) {
if !((int64(_la) & ^0x3f) == 0 && ((int64(1)<<_la)&201351168) != 0) {
var _ri = p.GetErrorHandler().RecoverInline(p)
localctx.(*UnaryContext).op = _ri
@ -1623,7 +1922,7 @@ func (p *PlanParser) expr(_p int) (localctx IExprContext) {
_la = p.GetTokenStream().LA(1)
if !(((_la)&-(0x1f+1)) == 0 && ((1<<uint(_la))&((1<<PlanParserMUL)|(1<<PlanParserDIV)|(1<<PlanParserMOD))) != 0) {
if !((int64(_la) & ^0x3f) == 0 && ((int64(1)<<_la)&229376) != 0) {
var _ri = p.GetErrorHandler().RecoverInline(p)
localctx.(*MulDivModContext).op = _ri
@ -1822,7 +2121,7 @@ func (p *PlanParser) expr(_p int) (localctx IExprContext) {
_la = p.GetTokenStream().LA(1)
if !(((_la)&-(0x1f+1)) == 0 && ((1<<uint(_la))&((1<<PlanParserLT)|(1<<PlanParserLE)|(1<<PlanParserGT)|(1<<PlanParserGE))) != 0) {
if !((int64(_la) & ^0x3f) == 0 && ((int64(1)<<_la)&960) != 0) {
var _ri = p.GetErrorHandler().RecoverInline(p)
localctx.(*RelationalContext).op = _ri
@ -2097,6 +2396,9 @@ func (p *PlanParser) Sempred(localctx antlr.RuleContext, ruleIndex, predIndex in
}
func (p *PlanParser) Expr_Sempred(localctx antlr.RuleContext, predIndex int) bool {
this := p
_ = this
switch predIndex {
case 0:
return p.Precpred(p.GetParserRuleContext(), 16)

View File

@ -1,7 +1,7 @@
// Code generated from Plan.g4 by ANTLR 4.9. DO NOT EDIT.
// Code generated from java-escape by ANTLR 4.11.1. DO NOT EDIT.
package planparserv2 // Plan
import "github.com/antlr/antlr4/runtime/Go/antlr"
import "github.com/antlr/antlr4/runtime/Go/antlr/v4"
// A complete Visitor for a parse tree produced by PlanParser.
type PlanVisitor interface {

View File

@ -7,7 +7,7 @@ import (
"github.com/milvus-io/milvus/internal/proto/planpb"
"github.com/milvus-io/milvus/pkg/util/typeutil"
"github.com/antlr/antlr4/runtime/Go/antlr"
"github.com/antlr/antlr4/runtime/Go/antlr/v4"
)
func handleExpr(schema *typeutil.SchemaHelper, exprStr string) interface{} {

View File

@ -3,7 +3,7 @@ package planparserv2
import (
"sync"
"github.com/antlr/antlr4/runtime/Go/antlr"
"github.com/antlr/antlr4/runtime/Go/antlr/v4"
antlrparser "github.com/milvus-io/milvus/internal/parser/planparserv2/generated"
)

View File

@ -5,7 +5,7 @@ import (
"github.com/stretchr/testify/assert"
"github.com/antlr/antlr4/runtime/Go/antlr"
"github.com/antlr/antlr4/runtime/Go/antlr/v4"
antlrparser "github.com/milvus-io/milvus/internal/parser/planparserv2/generated"
)

View File

@ -839,6 +839,7 @@ type Proxy interface {
}
// ProxyComponent defines the interface of proxy component.
//go:generate mockery --name=ProxyComponent --output=../mocks --filename=mock_proxy.go --with-expecter
type ProxyComponent interface {
Proxy

View File

@ -0,0 +1,33 @@
package typeutil
import "github.com/milvus-io/milvus-proto/go-api/schemapb"
func GetRowCount(fieldData *schemapb.FieldData) int {
switch field := fieldData.Field.(type) {
case *schemapb.FieldData_Scalars:
switch scalars := field.Scalars.Data.(type) {
case *schemapb.ScalarField_BoolData:
return len(scalars.BoolData.GetData())
case *schemapb.ScalarField_IntData:
return len(scalars.IntData.GetData())
case *schemapb.ScalarField_LongData:
return len(scalars.LongData.GetData())
case *schemapb.ScalarField_FloatData:
return len(scalars.FloatData.GetData())
case *schemapb.ScalarField_DoubleData:
return len(scalars.DoubleData.GetData())
case *schemapb.ScalarField_StringData:
return len(scalars.StringData.GetData())
case *schemapb.ScalarField_BytesData:
return len(scalars.BytesData.GetData())
}
case *schemapb.FieldData_Vectors:
switch vectors := field.Vectors.Data.(type) {
case *schemapb.VectorField_FloatVector:
return int(int64(len(vectors.FloatVector.GetData())) / field.Vectors.GetDim())
case *schemapb.VectorField_BinaryVector:
return int(int64(len(vectors.BinaryVector)*8) / field.Vectors.GetDim())
}
}
return 0
}

View File

@ -120,7 +120,7 @@ func TestGlobalMethods(t *testing.T) {
err = ZstdCompress(strings.NewReader(data), compressed, zstd.WithWindowSize(3))
assert.Error(t, err)
err = ZstdDecompress(compressed, origin, zstd.WithDecoderConcurrency(0))
err = ZstdDecompress(compressed, origin, zstd.WithDecoderConcurrency(-1))
assert.Error(t, err)
}

View File

@ -89,6 +89,8 @@ type ComponentParam struct {
IndexNodeGrpcClientCfg GrpcClientConfig
IntegrationTestCfg integrationTestConfig
MysqldConfig mysqldConfig
}
// Init initialize once
@ -137,6 +139,8 @@ func (p *ComponentParam) init() {
p.IndexNodeGrpcClientCfg.Init("indexNode", &p.BaseTable)
p.IntegrationTestCfg.init(&p.BaseTable)
p.MysqldConfig.init(&p.BaseTable)
}
func (p *ComponentParam) GetComponentConfigurations(componentName string, sub string) map[string]string {
@ -2300,3 +2304,17 @@ func (p *integrationTestConfig) init(base *BaseTable) {
}
p.IntegrationMode.Init(base.mgr)
}
type mysqldConfig struct {
TCPPort ParamItem `refreshable:"false"`
}
func (p *mysqldConfig) init(base *BaseTable) {
p.TCPPort = ParamItem{
Key: "mysqld.tcpPort",
Version: "2.3",
DefaultValue: "3306",
PanicIfEmpty: false,
}
p.TCPPort.Init(base.mgr)
}

View File

@ -33,10 +33,10 @@ beginTime=`date +%s`
if [[ $(uname -s) == "Darwin" && "$(uname -m)" == "arm64" ]]; then
APPLE_SILICON_FLAG="-tags dynamic"
fi
for d in $(go list ./internal/... | grep -v -e vendor -e kafka -e planparserv2/generated -e mocks); do
for d in $(go list ./internal/... | grep -v -e vendor -e kafka -e planparserv2/generated -e mocks -e mysqld/parser/antlrparser/parser); do
go test -race ${APPLE_SILICON_FLAG} -v -coverpkg=./... -coverprofile=profile.out -covermode=atomic "$d"
if [ -f profile.out ]; then
grep -v kafka profile.out | grep -v planparserv2/generated | grep -v mocks | sed '1d' >> ${FILE_COVERAGE_INFO}
grep -v kafka profile.out | grep -v planparserv2/generated | grep -v mocks | grep -v mysqld/parser/antlrparser/parser | sed '1d' >> ${FILE_COVERAGE_INFO}
rm profile.out
fi
done

View File

@ -26,6 +26,14 @@ if [[ "$OSTYPE" == "linux-gnu"* ]]; then
fi
fi
# This should be set when the project depends on two pb packages
# who were generated by same file name. For example, project depends
# on libA and libB, where libA has a package schemapb which is generated
# by `schema.proto` inside libA, and same to libB, then namespace
# will conflict if this environment is not set.
# TODO: check if upgrading protoc works.
export GOLANG_PROTOBUF_REGISTRATION_CONFLICT=warn
echo "Starting rootcoord..."
nohup ./bin/milvus run rootcoord > /tmp/rootcoord.log 2>&1 &

View File

@ -26,5 +26,13 @@ if [[ "$OSTYPE" == "linux-gnu"* ]]; then
fi
fi
# This should be set when the project depends on two pb packages
# who were generated by same file name. For example, project depends
# on libA and libB, where libA has a package schemapb which is generated
# by `schema.proto` inside libA, and same to libB, then namespace
# will conflict if this environment is not set.
# TODO: check if upgrading protoc works.
export GOLANG_PROTOBUF_REGISTRATION_CONFLICT=warn
echo "Starting standalone..."
nohup ./bin/milvus run standalone > /tmp/standalone.log 2>&1 &

Binary file not shown.