Skip to content

Commit

Permalink
Export of internal ZetaSQL changes.
Browse files Browse the repository at this point in the history
--
Change by ZetaSQL Team <[email protected]>:
No public description
--
Change by ZetaSQL Team <[email protected]>:
Removed the `depth_limit_detector_test_cases_test` from zetasql.
--
Change by John Fremlin <[email protected]>:
Internal change

GitOrigin-RevId: e6d88e9515744687cd24e0c05460c1ee362c7f69
Change-Id: I056cb0c1a190714ff4e94715ec8ffe8dbb716013
  • Loading branch information
ZetaSQL Team authored and KimiWaRokkuWoKikanai committed Oct 7, 2023
1 parent 1bf358a commit a745bef
Show file tree
Hide file tree
Showing 7 changed files with 105 additions and 381 deletions.
1 change: 1 addition & 0 deletions bazel/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ exports_files([
"bison.bzl",
"flex.bzl",
"maven_install.json",
"textmapper.bzl",
"zetasql_deps_step_1.bzl",
"zetasql_deps_step_2.bzl",
"zetasql_deps_step_3.bzl",
Expand Down
75 changes: 75 additions & 0 deletions bazel/textmapper.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# Copyright 2023 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""Definitions to generate parsers through Textmapper"""

def tm_syntax(
name,
src,
outs,
visibility = None,
compatible_with = None,
templates = None,
textmapper = "@com_github_inspirer_textmapper//cmd/textmapper:textmapper"):
"""Generates the requested outs from Textmapper sources.
Example usage:
tm_syntax(
name = "syntax",
src = "java.tm",
outs = [
"lexer.go",
"lexer_tables.go",
"token.go",
],
)
Outs should enumerate all expected outputs for Textmapper.
Args:
name: Unique identifier for the build rule.
src: Textmapper file for the language.
outs: Expected outputs from Textmapper.
visibility: Visibility of the rule.
compatible_with: Standard Blaze compatible_with attribute.
templates: Location of the Textmapper templates to use.
textmapper: Build target for Textmapper tool.
"""

if not templates:
tmpl_arg = ""
srcs = [src]
else:
tmpl_arg = "-i $$(dirname $$(echo $(locations {templates}) | cut --delimiter ' ' --fields 1))".format(
templates = templates,
)
srcs = [src, templates]
tm_cmd = """
$(location {textmapper}) generate -o $(@D) {tmpl_arg} $(location {src})
""".format(
src = src,
textmapper = textmapper,
tmpl_arg = tmpl_arg,
)
native.genrule(
name = name,
srcs = srcs,
outs = outs,
cmd = tm_cmd,
visibility = visibility,
compatible_with = compatible_with,
tools = [textmapper],
exec_compatible_with = ["@platforms//os:linux", "@platforms//os:macos"],
)
22 changes: 22 additions & 0 deletions bazel/zetasql_deps_step_1.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,28 @@ load("@com_google_zetasql//bazel:zetasql_bazel_version.bzl", "zetasql_bazel_vers
def zetasql_deps_step_1(add_bazel_version = True):
if add_bazel_version:
zetasql_bazel_version()

# Install newer versions of io_bazel_rules_go and gazelle to import Textmapper from github
# Make sure this is installed first. Otherwise, grpc_deps.bzl would attempt to use older
# versions, which have some bugs when downloading the go toolchains.
http_archive(
name = "io_bazel_rules_go",
sha256 = "278b7ff5a826f3dc10f04feaf0b70d48b68748ccd512d7f98bf442077f043fe3",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.41.0/rules_go-v0.41.0.zip",
"https://github.com/bazelbuild/rules_go/releases/download/v0.41.0/rules_go-v0.41.0.zip",
],
)

http_archive(
name = "bazel_gazelle",
sha256 = "d3fa66a39028e97d76f9e2db8f1b0c11c099e8e01bf363a923074784e451f809",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/bazel-gazelle/releases/download/v0.33.0/bazel-gazelle-v0.33.0.tar.gz",
"https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.33.0/bazel-gazelle-v0.33.0.tar.gz",
],
)

http_archive(
name = "platforms",
sha256 = "5308fc1d8865406a49427ba24a9ab53087f17f5266a7aabbfc28823f3916e1ca",
Expand Down
6 changes: 6 additions & 0 deletions bazel/zetasql_deps_step_2.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

""" Step 2 to load ZetaSQL dependencies. """

load("@bazel_gazelle//:deps.bzl", "go_repository")
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

# Followup from zetasql_deps_step_1.bzl
Expand Down Expand Up @@ -407,6 +408,11 @@ alias(
m4_register_toolchains(version = "1.4.18")
flex_register_toolchains(version = "2.6.4")
bison_register_toolchains(version = "3.3.2")
go_repository(
name = "com_github_inspirer_textmapper",
commit = "e0aa14dc6db169c7afdf6908e810b5d12bbae2db",
importpath = "github.com/inspirer/textmapper",
)

##########################################################################
# Rules which depend on rules_foreign_cc
Expand Down
36 changes: 0 additions & 36 deletions zetasql/compliance/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -328,42 +328,6 @@ cc_library(
],
)

cc_test(
name = "depth_limit_detector_test_cases_test",
size = "large",
srcs = ["depth_limit_detector_test_cases_test.cc"],
data = [
"//zetasql/public/functions:array_find_mode_proto",
"//zetasql/public/functions:rounding_mode_proto",
"//zetasql/testdata:test_proto3_proto",
"//zetasql/testdata:test_schema_proto",
"@com_google_googleapis//google/type:date_proto",
"@com_google_googleapis//google/type:latlng_proto",
"@com_google_googleapis//google/type:timeofday_proto",
"@com_google_protobuf//:timestamp_proto",
"@com_google_protobuf//:wrappers_proto",
],
shard_count = 30,
deps = [
":depth_limit_detector_test_cases",
":test_driver",
"//zetasql/base/testing:status_matchers",
"//zetasql/base/testing:zetasql_gtest_main",
"//zetasql/common:thread_stack",
"//zetasql/parser",
"//zetasql/public:language_options",
"//zetasql/public:options_cc_proto",
"//zetasql/public:parse_helpers",
"//zetasql/public/types",
"//zetasql/reference_impl:reference_driver",
"//zetasql/testing:type_util",
"@com_google_absl//absl/flags:flag",
"@com_google_absl//absl/status",
"@com_google_absl//absl/strings",
"@com_google_absl//absl/time",
],
)

cc_library(
name = "compliance_test_cases",
testonly = 1,
Expand Down
Loading

0 comments on commit a745bef

Please sign in to comment.