Skip to content

Commit

Permalink
fix: migrate to use file as argument instead of table
Browse files Browse the repository at this point in the history
  • Loading branch information
ashish10alex committed Jun 24, 2024
1 parent 24c0335 commit a229763
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 17 deletions.
23 changes: 14 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,21 +34,22 @@ Cost of of running all tables in Dataform project
```bash
dj --json-file <path-to-json-file> table-ops cost --all
```
OR (using stdin as input )
**OR** (using stdin as input )

```bash
dataform compile --json | dj table-ops cost --all
`
```

Cost of of running a file

Cost of of running a table
```bash
dj --json-file <path-to-json-file> table-ops cost --table <table-name>
dj --json-file <path-to-json-file> table-ops cost --file <file-name-wo-extension>
```

Compiled query for a table
Compiled query for a file

```bash
dj --json-file <path-to-json-file> table-ops query --table <table-name>
dj --json-file <path-to-json-file> table-ops query --file <file-name-wo-extension>
```

List unique tags in Dataform project
Expand All @@ -73,13 +74,17 @@ curl -sSfL https://raw.githubusercontent.com/ashish10alex/dj/main/install_latest
```bash
go install github.com/ashish10alex/dj@latest
```
This instals the binary `dj` to $GOBIN, which defaults to $GOPATH/bin.
This installs the binary `dj` to $GOBIN, which defaults to $GOPATH/bin.

Or you can manually clone the repository and build the cli and add the cli to your system path
**OR**

Manually clone the repository and build the cli and add the cli to your system path

```bash
git clone <repo-url>
just build # this assumes that you have a ~/bin directory which is in your PATH and just cli is installed
go build -o dj
mv dj /usr/local/bin/dj

```

### [To BigQuery](#to-bigquery)
Expand Down
12 changes: 5 additions & 7 deletions cmd/table_ops/table_ops.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,8 @@ var tableOpsCostCmd = &cobra.Command{
projectId := jsonData.GetTargetGcpProjectId()
jsonData.GetDryRunForAllTables(projectId, keyFile, location, includeAssertions, compact)

} else if cmd.Flag("table").Value.String() != "" {
// NOTE: Neovim front end is passing the file name not the table name.
// Which is why we have the logic to infer the table name from file name
fileName := cmd.Flag("table").Value.String()
} else if cmd.Flag("file").Value.String() != "" {
fileName := cmd.Flag("file").Value.String()
jsonData, err := readJson(jsonFile)
if err != nil {
log.Fatal("Error parsing json: ", err.Error())
Expand Down Expand Up @@ -100,10 +98,10 @@ var tableOpsCostCmd = &cobra.Command{
func init() {
cmd.RootCmd.AddCommand(tableopsCmd)

tableOpsCostCmd.Flags().BoolP("all", "a", false, "Get cost for all tables")
tableOpsCostCmd.Flags().BoolP("compact", "c", true, "compact af")
tableOpsCostCmd.Flags().BoolP("all", "a", false, "Cost for all tables")
tableOpsCostCmd.Flags().BoolP("compact", "c", true, "Compact JSON response. Excludes compiled query")
tableOpsCostCmd.Flags().BoolP("include-assertions", "i", false, "Include assertions in the cost")
tableOpsCostCmd.Flags().StringP("table", "t", "", "Get cost for a specific table")
tableOpsCostCmd.Flags().StringP("file", "f", "", "Get cost for a specific file, file name should be passed without the extension")
tableopsCmd.Flags().BoolP("list-tables", "u", false, "List all tables in the project")
tableopsCmd.AddCommand(tableOpsCostCmd)
}
2 changes: 1 addition & 1 deletion justfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ test_tag_ops:
go run . --json-file test/op.json tag-ops cost --all

test_single_table_ops_cost:
go run . --json-file test/dpr.json table-ops cost --table=table_name
go run . --json-file test/dpr.json table-ops cost --file=0400_WIP_HISTORY

debug:
dlv debug -- -j test/dpr.json tag-ops -u
Expand Down

0 comments on commit a229763

Please sign in to comment.