Skip to content

Commit 9ef7ca0

Browse files
authored
feat: graduate parsecmd experiment (#4253)
1 parent 67e865b commit 9ef7ca0

File tree

2 files changed

+6
-21
lines changed

2 files changed

+6
-21
lines changed

internal/cmd/parse.go

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,28 +16,20 @@ import (
1616

1717
var parseCmd = &cobra.Command{
1818
Use: "parse [file]",
19-
Short: "Parse SQL and output the AST as JSON (experimental)",
19+
Short: "Parse SQL and output the AST as JSON",
2020
Long: `Parse SQL from a file or stdin and output the abstract syntax tree as JSON.
2121
22-
This command is experimental and requires the 'parsecmd' experiment to be enabled.
23-
Enable it by setting: SQLCEXPERIMENT=parsecmd
24-
2522
Examples:
2623
# Parse a SQL file with PostgreSQL dialect
27-
SQLCEXPERIMENT=parsecmd sqlc parse --dialect postgresql schema.sql
24+
sqlc parse --dialect postgresql schema.sql
2825
2926
# Parse from stdin with MySQL dialect
30-
echo "SELECT * FROM users" | SQLCEXPERIMENT=parsecmd sqlc parse --dialect mysql
27+
echo "SELECT * FROM users" | sqlc parse --dialect mysql
3128
3229
# Parse SQLite SQL
33-
SQLCEXPERIMENT=parsecmd sqlc parse --dialect sqlite queries.sql`,
30+
sqlc parse --dialect sqlite queries.sql`,
3431
Args: cobra.MaximumNArgs(1),
3532
RunE: func(cmd *cobra.Command, args []string) error {
36-
env := ParseEnv(cmd)
37-
if !env.Experiment.ParseCmd {
38-
return fmt.Errorf("parse command requires the 'parsecmd' experiment to be enabled.\nSet SQLCEXPERIMENT=parsecmd to use this command")
39-
}
40-
4133
dialect, err := cmd.Flags().GetString("dialect")
4234
if err != nil {
4335
return err

internal/opts/experiment.go

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import (
1414
//
1515
// Available experiments:
1616
//
17-
// (none currently defined - add experiments here as they are introduced)
17+
// analyzerv2 - enables database-only analyzer mode
1818
//
1919
// Example usage:
2020
//
@@ -28,8 +28,6 @@ type Experiment struct {
2828
// AnalyzerV2 enables the database-only analyzer mode (analyzer.database: only)
2929
// which uses the database for all type resolution instead of parsing schema files.
3030
AnalyzerV2 bool
31-
// ParseCmd enables the parse subcommand which outputs AST as JSON.
32-
ParseCmd bool
3331
}
3432

3533
// ExperimentFromEnv returns an Experiment initialized from the SQLCEXPERIMENT
@@ -77,7 +75,7 @@ func ExperimentFromString(val string) Experiment {
7775
// known experiment.
7876
func isKnownExperiment(name string) bool {
7977
switch strings.ToLower(name) {
80-
case "analyzerv2", "parsecmd":
78+
case "analyzerv2":
8179
return true
8280
default:
8381
return false
@@ -89,8 +87,6 @@ func setExperiment(e *Experiment, name string, enabled bool) {
8987
switch strings.ToLower(name) {
9088
case "analyzerv2":
9189
e.AnalyzerV2 = enabled
92-
case "parsecmd":
93-
e.ParseCmd = enabled
9490
}
9591
}
9692

@@ -100,9 +96,6 @@ func (e Experiment) Enabled() []string {
10096
if e.AnalyzerV2 {
10197
enabled = append(enabled, "analyzerv2")
10298
}
103-
if e.ParseCmd {
104-
enabled = append(enabled, "parsecmd")
105-
}
10699
return enabled
107100
}
108101

0 commit comments

Comments
 (0)