Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
5 changes: 4 additions & 1 deletion PLAN.md
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,10 @@ darkwing/
backtracking), race-clean parallel corpus run.
7. **Pin advance to v2.0.0 final** — re-vendor grammar, re-derive corpus
expectations, review diffs; this rehearses the § Regeneration workflow
that every later DuckDB release will use.
that every later DuckDB release will use. Exercised again for v2.0.1
(2026-12): `.` lexes as an operator unless a digit follows, dotted
names, arrow/JSON operator chains, CREATE INDEX CONCURRENTLY, scoped
SET/RESET TIME ZONE, nested qualified names and SHOW EXTERNAL RESOURCES.
8. **sqlc integration** (in the sqlc repo, separate effort) — new
`internal/engine/duckdb`: catalog defaults, `convert.go` (darkwing AST →
`sql/ast`), `reserved.go` from darkwing's keyword table, parameter
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ to packrat), and `cmd/difftest` mutates corpus seeds and diffs darkwing's
verdicts against the pinned CLI (run nightly in CI while the nightly
artifact matches the pin).

Next: advancing the pin to the v2.0.0 tag when it lands (milestone 7),
then sqlc integration.
The pin tracks DuckDB releases (currently v2.0.1, see
`internal/grammar/README.md`). Next: sqlc integration.

```
$ go run ./cmd/debug-parse 'SELECT 1'
Expand Down
13 changes: 10 additions & 3 deletions ast/ddl.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ package ast
type QualifiedName struct {
Catalog string `json:"catalog,omitempty"`
Schema string `json:"schema,omitempty"`
Name string `json:"name"`
// Qualification is the full qualification path when it is deeper
// than catalog.schema (a nested schema chain); Catalog and Schema
// then hold QualifiedName::Catalog()/Schema() of it.
Qualification []string `json:"qualification,omitempty"`
Name string `json:"name"`
}

// OnCreateConflict mirrors DuckDB's OnCreateConflict: what CREATE does
Expand Down Expand Up @@ -230,8 +234,11 @@ type IndexElement struct {
// CreateIndexInfo is CREATE INDEX. Port of CreateIndexInfo.
type CreateIndexInfo struct {
CreateInfoBase
Unique bool `json:"unique,omitempty"`
Table QualifiedName `json:"table"`
Unique bool `json:"unique,omitempty"`
// Concurrently records CREATE INDEX CONCURRENTLY; DuckDB accepts the
// keyword and ignores it.
Concurrently bool `json:"concurrently,omitempty"`
Table QualifiedName `json:"table"`
// IndexType is the USING method (ART by default upstream; recorded
// verbatim here).
IndexType string `json:"index_type,omitempty"`
Expand Down
27 changes: 17 additions & 10 deletions ast/misc.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,10 @@ type UseStatement struct {
stmtBase
Catalog string `json:"catalog,omitempty"`
Name string `json:"name"`
// Path is the full target when it is deeper than catalog.schema
// (USE db.parent.child, a nested schema); Catalog and Name then hold
// its first and last components.
Path []string `json:"path,omitempty"`
}

func (s *UseStatement) Children() []Node { return nil }
Expand Down Expand Up @@ -389,23 +393,22 @@ const (
ExternalResourceCreate ExternalResourceOperation = "CREATE"
ExternalResourceRegister ExternalResourceOperation = "REGISTER"
ExternalResourceDestroy ExternalResourceOperation = "DESTROY"
ExternalResourceShow ExternalResourceOperation = "SHOW"
)

// ExternalResourceStatement is CREATE/REGISTER/DESTROY EXTERNAL RESOURCE
// and SHOW [ALL] EXTERNAL RESOURCES. Port of ExternalResourceStatement.
// ExternalResourceStatement is CREATE/REGISTER/DESTROY EXTERNAL RESOURCE.
// Port of ExternalResourceStatement. (SHOW [ALL] EXTERNAL RESOURCES is a
// query over duckdb_external_resources() since v2.0.1.)
type ExternalResourceStatement struct {
stmtBase
Operation ExternalResourceOperation `json:"operation"`
// Type is the resource type string literal of CREATE/REGISTER.
// Type is the resource type of CREATE/REGISTER: a string literal as
// written, or a bare (dotted) name folded to lowercase.
Type string `json:"type,omitempty"`
Name string `json:"name,omitempty"`
// Handle is the REGISTER ... FROM expression.
Handle Expr `json:"handle,omitempty"`
Options []GenericOption `json:"options,omitempty"`
// All is SHOW ALL EXTERNAL RESOURCES.
All bool `json:"all,omitempty"`
NamedParams []NamedParam `json:"named_param_map,omitempty"`
Handle Expr `json:"handle,omitempty"`
Options []GenericOption `json:"options,omitempty"`
NamedParams []NamedParam `json:"named_param_map,omitempty"`
}

func (s *ExternalResourceStatement) Children() []Node {
Expand Down Expand Up @@ -438,7 +441,11 @@ type CommentOnStatement struct {
Catalog string `json:"catalog,omitempty"`
Schema string `json:"schema,omitempty"`
Name string `json:"name"`
Column string `json:"column,omitempty"`
// Qualification is the full path when it is deeper than
// catalog.schema.name (nested schemas); Catalog and Schema then hold
// QualifiedName::Catalog()/Schema() of it.
Qualification []string `json:"qualification,omitempty"`
Column string `json:"column,omitempty"`
// Value is the comment constant: a string or NULL.
Value Expr `json:"value"`
}
Expand Down
8 changes: 4 additions & 4 deletions internal/duckdbsrc/duckdbsrc.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ import (
// Pinned build identity. Advancing the pin means updating these alongside
// the vendored grammar and regenerated corpus.
const (
// PinnedCommit is the DuckDB source commit of the pin (the v2.0.0 tag).
PinnedCommit = "d54cbbe3df17e8e5ce68312f483b4155836112aa"
// PinnedCommit is the DuckDB source commit of the pin (the v2.0.1 tag).
PinnedCommit = "8d78114e90a53823803660bf821f6073ac87da8c"
// PinnedVersion is the CLI version string of the pinned release.
PinnedVersion = "v2.0.0"
PinnedVersion = "v2.0.1"
// ReleaseURL is where DuckDB serves the pinned release's CLI. Unlike
// the nightly bundle a tagged release never moves.
ReleaseURL = "https://github.com/duckdb/duckdb/releases/download/v2.0.0/duckdb_cli-linux-amd64.zip"
ReleaseURL = "https://github.com/duckdb/duckdb/releases/download/v2.0.1/duckdb_cli-linux-amd64.zip"
)

// EnvBinary is the environment variable naming the pinned CLI binary.
Expand Down
30 changes: 15 additions & 15 deletions internal/grammar/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ edit them by hand — changes happen only by advancing the pin (see PLAN.md,

- Upstream: https://github.com/duckdb/duckdb
- Source tree: `src/parser/peg/grammar/`
- Pinned commit: `d54cbbe3df17e8e5ce68312f483b4155836112aa` (tag `v2.0.0`, 2026-10-20)
- Matching oracle binary: DuckDB CLI `v2.0.0 d54cbbe3df` (the v2.0.0 release
- Pinned commit: `8d78114e90a53823803660bf821f6073ac87da8c` (tag `v2.0.1`, 2026-11-19)
- Matching oracle binary: DuckDB CLI `v2.0.1 8d78114e90` (the v2.0.1 release
CLI; see `internal/duckdbsrc`)

The pin follows the oracle binary: grammar, corpus expectations, and the
Expand All @@ -19,16 +19,16 @@ DuckDB is MIT-licensed; see `LICENSE.DUCKDB` at the repository root.
## File checksums (SHA-256)

```
d6a4de42cffd26db45a76460102ab4be7efeced1c401613f9604ed76e5ad55e7 statements/alter.gram
740e9b43dde5af17cd1e793cd1b0193578df7d1939fbe441ec85744d8e7a5207 statements/alter.gram
4bd5c409bb84e7b0fa189de1cf73c145ace1498138d2bc0d7c5fdea470815fd0 statements/analyze.gram
fb98930e1a251fec3a44a5443ab98ea02d9426fc96477aeb356654f2c55075fa statements/attach.gram
cf752ee0bae6b4f2940d63d701b18a533549a6a5f623f3f68f9d3c2e08637e33 statements/call.gram
0758036168b998cd2020a3fa2b358a978cc40de4d6706e84c04793dbca0e78e2 statements/checkpoint.gram
6408b038796b3fd125e8bf205b508997b17fabb1542f2e4d11af54c2e2270ad6 statements/comment.gram
098c3b3262e6e7ea5a2a337f2ba9608cbb76c02b915e1a3f23ad89f6560101b9 statements/common.gram
2aad2a422fa514f39eeab210f7ef3c1b1bb798fe15c620b963dea647e4a88296 statements/common.gram
19b1c24e05dd0fd5795e2ae5c5495583a10f0f6c1f4afcbfe5e4abfb360c7aba statements/connect.gram
be323c6f6b9ed544dcf0564bba7f14b56fa8158dce9bc0c5c1ca246a703ee4d4 statements/copy.gram
bbf148a4bd1f2b3d338966d97281f9c5e8ca581164972f11f2b92dd7f59c13a6 statements/create_index.gram
bc6ecbca6221011d0b51472eb0e85c9b69557eacaaa3c79154fa9978563447f7 statements/create_index.gram
831dbbe5fd612ddbd4aa448560acc290015080887917d8b2d2c1a38c9dffb3d7 statements/create_macro.gram
6f52aa63c7ea606817f8ed32b925f952fb38084de235161ebfc0601d75557494 statements/create_schema.gram
d145c7659cbda441cd380b7cbdda88adf84307c18148aeed46dbefbc41c72ec5 statements/create_secret.gram
Expand All @@ -39,23 +39,23 @@ b5bc5170347d26bff09e5b644ddd69b1f75d58611cf0de91161d1f9ec02be29c statements/cre
9ede97c886fa89f1c617914f88e3657192d34ae72bcf4803dee01e57cc2300c4 statements/create_view.gram
c1aa087a0af8cd88dc8e7d638e8e1a08a8348cad98d8c58e859b27bcf247ab30 statements/deallocate.gram
d82d170411ad444e768405279e56a50219e22dca69df846b8b7a021b49351bbd statements/delete.gram
c1242ea8a05cf628e152e189df9c94d866494e1b092553fcbb45142d0b3b92e7 statements/describe.gram
376176482397b9ae292f2de10e94127bbafd48cbbce1e76f30f73a4c7c8b4faf statements/describe.gram
ec5f4bd0ba34ecfefbf09f2d637bfaec2f7b84311a639aeee589b997d72abba9 statements/detach.gram
b9e071a89874e169a80bc7a6b547841c7a868b189af773204a0d60644e08ad96 statements/drop.gram
ebf785af485915028c38ce0acb70d1a4351181e8885f174e8867f5b37db378a9 statements/drop.gram
c39dbaed5de68045913b78bc15205885b2c36e3e9f37d9f37e1ac71aeb89b5b9 statements/execute.gram
306c0603ae5e1a72975f3739a238570038b8d5487a89997afde7101eafccc8e7 statements/explain.gram
507cca9d8af7c3a061e04a654ccda1671784c81a115418b3aff57f9157382b53 statements/export.gram
8105e1537dd51d3123b8dbb47c590751ccb1282ed160dff59d8c7848c16b48d0 statements/expression.gram
06592b807fbdfcd88c52abda051ea9ef44171f71e1f9b4a4c225aa03b0f4aa1f statements/external_resource.gram
5f0420aac8bd5e9b8fc8f62faf5d41ffdba52e1f17de916163bfe86214108956 statements/external_resource_source.gram
4b1870483c99e17d1afb3c3cfb31997f27cc0972dff0e40e89c610f799e430ff statements/explain.gram
4c34e6330647e87cf8ba4187c119caea286abf437ada18eb29add41b448a3a1a statements/export.gram
8c70a2123b67c0e1a482ae650a1c6f50417b54c7ff41c374c9a03590cf0e5e42 statements/expression.gram
d4fda1655faa814af2d7fdeb2fc02569be05b983b117717a41e3b9d6a0b65b56 statements/external_resource.gram
1c51760c06ceba0e2aba70516b4d9d2d12d1d0e290acd5f394cf2c22ec00d243 statements/external_resource_source.gram
d40b438c674ba10792691b16ea370a81d28dea3b7fe330d6a4b6273bf635330d statements/insert.gram
70b7794dac3294c87fc01049e26a8d486824db959bfc689af63a1edf58ac9ade statements/load.gram
fc79b1c72cf44db3457ab4b5b2b857d41deac54aeb39d71cc34d2a143a15dc16 statements/load.gram
de64fb79521407b537d4ab4f240b7bc5280e8bfb76d1cbfd56924d7a1e9d9601 statements/merge_into.gram
ca8a8d1e4d6e5911b83037c2aaf234a2f2680fec08f67825b20fed35375b86d6 statements/pivot.gram
68ba82f61baed8fd57bb29043d025b2aaff86da0bfde49bee711f67e1f0ff8c3 statements/pragma.gram
4bc9403d48ba71b584648a42b5bb2d5ca7294a7f2be862fc7bbcfd48df6c0d59 statements/prepare.gram
894bae17476ec7811bc21a3f085d51ae17cb2dc17e4e3b66f5e3e4f743b9266d statements/select.gram
1d500aeb6bdd88fc8e434bb116dde8192c13c9e7354017e596dc2ef46424288a statements/set.gram
a46d50c92ddfd88883905f459adc9ce768db665c60d90b59414e7b04e6a4ad50 statements/select.gram
76ed134814f18bbcd2408e5b8ae2db6cda004852f00096491322630f0ea754d6 statements/set.gram
2de0cc72aeb00b6b6247348bd06db8e9a088cecb2c20516e678fe4261c909877 statements/transaction.gram
eab0c287f27d034d33f81ddc8dfe92762c262369d6d1efe0d7ed6d94cee5da2e statements/update.gram
9c9f82bead64307f2c798bb6e812d2ae37434856e0ec7f0454ff21208f45aad9 statements/use.gram
Expand Down
2 changes: 1 addition & 1 deletion internal/grammar/duckdb/statements/alter.gram
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ AlterViewStmt <- 'VIEW' IfExists? BaseTableName RenameAlter

AlterSequenceStmt <- 'SEQUENCE' IfExists? QualifiedSequenceName AlterSequenceOptions

QualifiedSequenceName <- CatalogQualification? SchemaQualification? SequenceName
QualifiedSequenceName <- CatalogQualification? SchemaQualification* SequenceName

AlterSequenceOptions <- RenameAlterSequenceOptions / SetSequenceOption
RenameAlterSequenceOptions <- RenameAlter
Expand Down
1 change: 1 addition & 0 deletions internal/grammar/duckdb/statements/common.gram
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ FunctionName <- Identifier
ReservedFunctionName <- Identifier
ReservedTypeName <- Identifier
TableFunctionName <- Identifier
ReservedTableFunctionName <- Identifier
ConstraintName <- ColIdOrString
SequenceName <- Identifier
CollationName <- Identifier
Expand Down
3 changes: 2 additions & 1 deletion internal/grammar/duckdb/statements/create_index.gram
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
CreateIndexStmt <- UniqueIndex? 'INDEX' IfNotExists? IndexName? 'ON' BaseTableName IndexType? Parens(List(IndexElement)) WithList? WhereClause?
CreateIndexStmt <- UniqueIndex? 'INDEX' IndexConcurrently? IfNotExists? IndexName? 'ON' BaseTableName IndexType? Parens(List(IndexElement)) WithList? WhereClause?

WithList <- 'WITH' RelOptionOrOids
RelOptionOrOids <- RelOptionList / Oids
Expand All @@ -9,6 +9,7 @@ WithOids <- 'WITH'
WithoutOids <- 'WITHOUT'
IndexElement <- Expression DescOrAsc? NullsFirstOrLast?
UniqueIndex <- 'UNIQUE'
IndexConcurrently <- 'CONCURRENTLY'
IndexType <- 'USING' Identifier
RelOption <- RelOptionName RelOptionArgumentOpt?
RelOptionName <- DottedColLabel / StringLiteral
Expand Down
11 changes: 10 additions & 1 deletion internal/grammar/duckdb/statements/describe.gram
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
DescribeStatement <- ShowTables / ShowDeprecatedSelect / DescribeSelect / ShowAllTables / ShowByName / DescribeByName
DescribeStatement <- ShowExternalResourceTypes / ShowExternalResources / ShowTables / ShowDeprecatedSelect / DescribeSelect / ShowAllTables / ShowByName / DescribeByName

# "SHOW [ALL] EXTERNAL RESOURCES" is a query over duckdb_external_resources, so it works as a subquery too. It and
# ShowExternalResourceTypes come first: "SHOW ALL" alone is ShowAllTables, and "SHOW <name>" is ShowByName, and
# neither can be retried once matched.
ShowExternalResources <- ShowRule 'ALL'? 'EXTERNAL' 'RESOURCES' ShowExternalResourcesType?
# "WITH TYPE aws.s3tables.bucket" (or the type in quotes) restricts the listing (and the discovery) to one type.
ShowExternalResourcesType <- 'WITH' 'TYPE' ExternalResourceType
# "SHOW EXTERNAL RESOURCE TYPES" is a query over duckdb_external_resource_types, so it works as a subquery too.
ShowExternalResourceTypes <- ShowRule 'EXTERNAL' 'RESOURCE' 'TYPES'

# "DESCRIBE (query)" and "SUMMARIZE (query)" describe the query's columns. "SHOW (query)" does too but is deprecated,
# so ShowDeprecatedSelect is parsed yet suppressed from autocomplete (matcher_factory.cpp) - SHOW won't offer to complete a query.
Expand Down
2 changes: 1 addition & 1 deletion internal/grammar/duckdb/statements/drop.gram
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ DropIndex <- 'INDEX' IfExists? List(QualifiedIndexName)
QualifiedIndexName <- CatalogReservedSchemaIndex / SchemaReservedIndex / QualifiedIndexNameString
QualifiedIndexNameString <- IndexName
SchemaReservedIndex <- SchemaQualification ReservedIndexName
CatalogReservedSchemaIndex <- CatalogQualification ReservedSchemaQualification ReservedIndexName
CatalogReservedSchemaIndex <- CatalogQualification ReservedSchemaQualification+ ReservedIndexName
DropSequence <- 'SEQUENCE' IfExists? List(QualifiedSequenceName)
DropCollation <- 'COLLATION' IfExists? List(CollationName)
DropType <- 'TYPE' IfExists? List(QualifiedTypeName)
Expand Down
3 changes: 3 additions & 0 deletions internal/grammar/duckdb/statements/explain.gram
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,15 @@ ExplainableStatements <-
DropStatement /
ExecuteStatement /
InsertStatement /
InstallStatement /
LoadStatement /
MergeIntoStatement /
PragmaStatement /
PrepareStatement /
ExplainSelectStatement /
TransactionStatement /
TruncateStatement /
UpdateExtensionsStatement /
UpdateStatement /
VacuumStatement /
SetStatement /
Expand Down
3 changes: 2 additions & 1 deletion internal/grammar/duckdb/statements/export.gram
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
ExportStatement <- 'EXPORT' 'DATABASE' ExportSource? StringLiteral GenericCopyOptionList?
ExportStatement <- 'EXPORT' 'DATABASE' ExportSource? StringLiteral ExportOptions?
ExportSource <- CatalogName 'TO'
ExportOptions <- GenericCopyOptionList / SpecializedOptionList
ImportStatement <- 'IMPORT' 'DATABASE' StringLiteral
26 changes: 17 additions & 9 deletions internal/grammar/duckdb/statements/expression.gram
Original file line number Diff line number Diff line change
Expand Up @@ -151,11 +151,8 @@ SingleExpression <-
DefaultExpression

# LEVEL 1 (Lowest)
Expression <- LambdaArrowExpression
Expression <- LogicalOrExpression
ColumnDefaultExpr <- ColDefOrExpr
# LEVEL 1.5
LambdaArrowExpression <- LogicalOrExpression SingleArrowPair*
SingleArrowPair <- '->' LogicalOrExpression
LogicalOrExpression <- LogicalAndExpression LogicalOrExpressionTail*
LogicalOrExpressionTail <- 'OR' LogicalAndExpression
ColDefOrExpr <- ColDefAndExpr ColDefOrExpressionTail*
Expand Down Expand Up @@ -239,10 +236,19 @@ InSelectStatement <- Parens(SelectStatementInternal)
BetweenClause <- 'BETWEEN' Asymmetric? OtherOperatorExpression 'AND' OtherOperatorExpression
Asymmetric <- 'ASYMMETRIC'
# LEVEL 8
OtherOperatorExpression <- InfixOtherOperatorExpression / CustomPrefixExpression
OtherOperatorExpression <- InfixOtherOperatorExpression
InfixOtherOperatorExpression <- BitwiseExpression OtherOperatorTail*
CustomPrefixExpression <- OperatorLiteral OtherOperatorExpression
OtherOperatorTail <- OtherOperator BitwiseExpression
OtherOperatorTail <- AnyAllSubqueryTail / OtherOperatorExpressionTail / SingleArrowTail
AnyAllSubqueryTail <- AnyAllParsedOperator SubqueryReference
OtherOperatorExpressionTail <- OtherOperator BitwiseExpression
# '->' is the lambda arrow or the JSON extract operator. Its operand extends as far as possible (the lambda body),
# unless another arrow follows directly: then the arrows chain to the left, like in PostgreSQL.
SingleArrowTail <- '->' SingleArrowBody
SingleArrowBody <- ArrowChainBody / ArrowFullBody
ArrowChainBody <- BitwiseExpression ArrowChainTail+
ArrowChainTail <- DoubleArrowTail / SingleArrowTail
DoubleArrowTail <- '->>' BitwiseExpression
ArrowFullBody <- LogicalOrExpression
OtherOperator <-
AnyAllParsedOperator / NamedOtherOperator
AnyAllParsedOperator <- AnyAllOperator
Expand Down Expand Up @@ -279,11 +285,13 @@ CollateExpression <- AtTimeZoneExpression CollateExpressionTail*
CollateExpressionTail <- CollateOperator AtTimeZoneExpression
CollateOperator <- 'COLLATE'
# LEVEL 14
AtTimeZoneExpression <- PrefixExpression AtTimeZoneExpressionTail*
AtTimeZoneExpressionTail <- AtTimeZoneOperator PrefixExpression
AtTimeZoneExpression <- UnaryExpression AtTimeZoneExpressionTail*
AtTimeZoneExpressionTail <- AtTimeZoneOperator UnaryExpression
AtTimeZoneOperator <- 'AT' 'TIME' 'ZONE'
# LEVEL 15
UnaryExpression <- PrefixExpression / CustomPrefixExpression
PrefixExpression <- PrefixOperator* BaseExpression
CustomPrefixExpression <- OperatorLiteral TildeExpression
PrefixOperator <- QualifiedOperator / MinusPrefixOperator / PlusPrefixOperator
MinusPrefixOperator <- '-'
PlusPrefixOperator <- '+'
Expand Down
21 changes: 14 additions & 7 deletions internal/grammar/duckdb/statements/external_resource.gram
Original file line number Diff line number Diff line change
@@ -1,16 +1,23 @@
# Every statement about external resources, so the top-level Statement choice carries one entry
# rather than one per form.
ExternalResourceStatement <- CreateExternalResourceStmt / RegisterExternalResourceStmt / DestroyExternalResourceStmt / ShowExternalResourcesStmt / AttachToExternalResource / ConnectToExternalResource
# rather than one per form. SHOW [ALL] EXTERNAL RESOURCES is a query (describe.gram), so it can be a subquery.
ExternalResourceStatement <- CreateExternalResourceStmt / RegisterExternalResourceStmt / DestroyExternalResourceStmt / AttachToExternalResource / ConnectToExternalResource

CreateExternalResourceStmt <- 'CREATE' ExternalResourceKeyword StringLiteral AttachAlias? ExternalResourceCreationOptions?
RegisterExternalResourceStmt <- 'REGISTER' ExternalResourceKeyword StringLiteral AttachAlias? 'FROM' Expression
CreateExternalResourceStmt <- 'CREATE' ExternalResourceKeyword ExternalResourceType AttachAlias? ExternalResourceCreationOptions?
RegisterExternalResourceStmt <- 'REGISTER' ExternalResourceKeyword ExternalResourceType AttachAlias? 'FROM' Expression
DestroyExternalResourceStmt <- 'DESTROY' ExternalResourceKeyword ColId
ShowExternalResourcesStmt <- 'SHOW' ShowAllModifier? 'EXTERNAL' 'RESOURCES'
ShowAllModifier <- 'ALL'

# Syntax only: the keyword pair every singular form repeats. The plural in SHOW cannot share it.
# Syntax only: the keyword pair every singular form repeats.
ExternalResourceKeyword <- 'EXTERNAL' 'RESOURCE'

# The type of a resource, as the provider registered it: aws.s3tables.bucket. In quotes it is taken as written; spelled
# bare it is folded to lowercase (TransformExternalResourceTypeName). A type with other characters in it, or one
# spelled with spaces around the dots, goes in quotes.
ExternalResourceType <- StringLiteral / ExternalResourceTypeName
ExternalResourceTypeName <- BareName
# A name spelled without quotes: a dotted name (DottedName, load.gram: labels separated by single dots, nothing in
# between) or a plain word
BareName <- DottedName / ColId

# The recipe's create params. Its own rule rather than AttachOptions: the two option bags are
# distinct, and a statement can carry both.
ExternalResourceCreationOptions <- GenericCopyOptionList
Loading
Loading