Skip to content

Commit

Permalink
Merge pull request #66 from Matts966/feature/upgrade-zetasql
Browse files Browse the repository at this point in the history
Upgrade ZetaSQL to support pivot functions
  • Loading branch information
Matts966 authored Jun 7, 2021
2 parents 34061b5 + 910c2c9 commit 612ad4d
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 36 deletions.
2 changes: 1 addition & 1 deletion .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@
# c++1z was used prior to c++17 being standardized, and is therefore more
# widely accepted by compilers. This may lead to strange behavior or compiler
# errors in earlier compilers.
build --cxxopt="-std=c++1z"
build --cxxopt="-std=c++1z" --features=-supports_dynamic_linker
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
bazel-*
.vscode
.cache
2 changes: 1 addition & 1 deletion WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")

git_repository(
name = "com_google_zetasql",
commit = "2020.10.1",
commit = "dd883180de6387ad80bcf7534b5aae8191e66621",
remote = "https://github.com/google/zetasql",
patches = ["@com_github_Matts966_alphasql//bazel:zetasql.patch"],
)
Expand Down
6 changes: 4 additions & 2 deletions alphasql/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,10 @@ cc_library(
"@com_google_zetasql//zetasql/public:simple_catalog",
"@com_google_zetasql//zetasql/public:type",
"@com_google_zetasql//zetasql/public:analyzer",
"@com_google_zetasql//zetasql/analyzer:analyzer_impl",
"@com_google_zetasql//zetasql/analyzer:resolver",
"@com_google_zetasql//zetasql/public:language_options",
"@com_google_zetasql//zetasql/parser:parser",
"@com_google_zetasql//zetasql/analyzer",
"@boost//:property_tree",
"@com_google_absl//absl/strings",
":table_name_resolver"
Expand Down Expand Up @@ -71,6 +72,7 @@ cc_binary(
"@com_google_zetasql//zetasql/base:status",
"@com_google_zetasql//zetasql/base:statusor",
"@com_google_zetasql//zetasql/public:analyzer",
"@com_google_zetasql//zetasql/analyzer:analyzer_impl",
"@com_google_zetasql//zetasql/public:catalog",
"@com_google_zetasql//zetasql/public:evaluator",
"@com_google_zetasql//zetasql/public:evaluator_table_iterator",
Expand Down Expand Up @@ -106,7 +108,7 @@ cc_library(
name = "dag_lib",
hdrs = ["dag_lib.h"],
deps = [
"@com_google_zetasql//zetasql/analyzer",
"@com_google_zetasql//zetasql/analyzer:analyzer_impl",
"@com_google_zetasql//zetasql/resolved_ast",
"@com_google_absl//absl/flags:flag",
"@com_google_absl//absl/flags:parse",
Expand Down
57 changes: 26 additions & 31 deletions bazel/zetasql.patch
Original file line number Diff line number Diff line change
@@ -1,47 +1,41 @@
diff --git zetasql/analyzer/BUILD zetasql/analyzer/BUILD
index 91c73c6..57e5609 100644
--- zetasql/analyzer/BUILD
+++ zetasql/analyzer/BUILD
@@ -14,7 +14,7 @@
# limitations under the License.
#
@@ -18,7 +18,7 @@ load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
load(":builddefs.bzl", "gen_analyzer_test")

package(
- default_visibility = ["//zetasql/base:zetasql_implementation"],
+ default_visibility = ["//visibility:public"],
)

cc_library(

filegroup(
diff --git zetasql/base/BUILD zetasql/base/BUILD
index 75c8e3e..7874e07 100644
--- zetasql/base/BUILD
+++ zetasql/base/BUILD
@@ -17,7 +17,7 @@
licenses(["notice"]) # Apache v2.0

package(
- default_visibility = [":zetasql_implementation"],
+ default_visibility = ["//visibility:public"],
)

package_group(

--- zetasql/common/BUILD
+++ zetasql/common/BUILD
@@ -14,4 +14,4 @@
# limitations under the License.

package(
- default_visibility = ["//zetasql/base:zetasql_implementation"],
+ default_visibility = ["//visibility:public"],

package_group(
diff --git zetasql/parser/BUILD zetasql/parser/BUILD
index 5c3c636..5404163 100644
--- zetasql/parser/BUILD
+++ zetasql/parser/BUILD
@@ -17,7 +17,7 @@ load("//bazel:bison.bzl", "genyacc")
@@ -20,7 +20,7 @@ load("//bazel:bison.bzl", "genyacc")
load("//bazel:flex.bzl", "genlex")

package(
- default_visibility = ["//zetasql/base:zetasql_implementation"],
+ default_visibility = ["//visibility:public"],
)

genrule(

--- zetasql/public/simple_catalog.h
Expand All @@ -59,14 +53,15 @@
// Construct a Catalog with catalog name <name>.
//

--- zetasql/resolved_ast/BUILD
+++ zetasql/resolved_ast/BUILD
@@ -16,7 +16,7 @@

load("//zetasql/resolved_ast:build_rules.bzl", "gen_resolved_ast_files")

-package(default_visibility = ["//zetasql/base:zetasql_implementation"])
+package(default_visibility = ["//visibility:public"])

py_binary(
name = "gen_resolved_ast",
diff --git zetasql/public/sql_formatter.cc zetasql/public/sql_formatter.cc
index 26e52ed..28e8928 100644
--- zetasql/public/sql_formatter.cc
+++ zetasql/public/sql_formatter.cc
@@ -72,6 +72,7 @@ absl::Status FormatSql(const std::string& sql, std::string* formatted_sql) {
std::vector<ParseToken> parse_tokens;
ParseTokenOptions options;
options.stop_at_end_of_statement = true;
+ options.include_comments = true;
const int statement_start = location.byte_position();
const absl::Status token_status =
GetParseTokens(options, &location, &parse_tokens);
2 changes: 1 addition & 1 deletion samples/sample-ci/alphacheck_stdout.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Analyzing "samples/sample-ci/sample/create_datawarehouse3.sql"
ERROR: INVALID_ARGUMENT: Table not found: `bigquery-public-data.samples.gsod` [at samples/sample-ci/sample/create_datawarehouse3.sql:5:3]
catalog:
dataset.main
tablename2
dataset.main
tablename1

0 comments on commit 612ad4d

Please sign in to comment.