├── .github ├── ISSUE_TEMPLATE │ └── bug_report.yml └── workflows │ ├── HighPriorityIssues.yml │ ├── c_tests.yml │ ├── distribution.yml │ └── main_distribution.yml ├── .gitignore ├── .gitmodules ├── CMakeLists.txt ├── LICENSE ├── Makefile ├── README.md ├── data ├── bug-17 │ └── test_table.parquet ├── iceberg │ ├── data │ │ ├── .00000-0-82367eae-71e8-4631-a319-01afaf7979c8-0-00001.parquet.crc │ │ ├── .00000-2-00930251-3748-4604-9f2c-50874f693b60-0-00001.parquet.crc │ │ ├── .00001-1-82367eae-71e8-4631-a319-01afaf7979c8-0-00001.parquet.crc │ │ ├── 00000-0-82367eae-71e8-4631-a319-01afaf7979c8-0-00001.parquet │ │ ├── 00000-2-00930251-3748-4604-9f2c-50874f693b60-0-00001.parquet │ │ └── 00001-1-82367eae-71e8-4631-a319-01afaf7979c8-0-00001.parquet │ └── metadata │ │ ├── .5b77c0d5-7fa7-482c-b332-cddaa0d25626-m0.avro.crc │ │ ├── .7ccac08a-42e7-4aef-b0b6-cf5365ac2df4-m0.avro.crc │ │ ├── .snap-3384446302073244860-1-5b77c0d5-7fa7-482c-b332-cddaa0d25626.avro.crc │ │ ├── .snap-4118182924578855064-1-7ccac08a-42e7-4aef-b0b6-cf5365ac2df4.avro.crc │ │ ├── .v1.metadata.json.crc │ │ ├── .v2.metadata.json.crc │ │ ├── .v3.metadata.json.crc │ │ ├── .version-hint.text.crc │ │ ├── 5b77c0d5-7fa7-482c-b332-cddaa0d25626-m0.avro │ │ ├── 7ccac08a-42e7-4aef-b0b6-cf5365ac2df4-m0.avro │ │ ├── snap-3384446302073244860-1-5b77c0d5-7fa7-482c-b332-cddaa0d25626.avro │ │ ├── snap-4118182924578855064-1-7ccac08a-42e7-4aef-b0b6-cf5365ac2df4.avro │ │ ├── v1.metadata.json │ │ ├── v2.metadata.json │ │ ├── v3.metadata.json │ │ └── version-hint.text └── parquet-testing │ ├── glob │ ├── t1.parquet │ └── t2.parquet │ └── lineitem-top10000.gzip.parquet ├── extension_config.cmake ├── scripts ├── dependencies.R ├── generate_custom_functions.py └── update_substrait.py ├── src ├── custom_extensions.cpp ├── custom_extensions_generated.cpp ├── from_substrait.cpp ├── include │ ├── custom_extensions │ │ └── custom_extensions.hpp │ ├── from_substrait.hpp │ ├── substrait_extension.hpp │ └── to_substrait.hpp ├── substrait_extension.cpp └── to_substrait.cpp ├── test ├── c │ ├── CMakeLists.txt │ ├── main.cpp │ ├── test_projection.cpp │ ├── test_substrait_c_api.cpp │ ├── test_substrait_c_utils.cpp │ └── test_substrait_c_utils.hpp └── sql │ ├── test_between.test │ ├── test_custom_function.test │ ├── test_direct_scan.test │ ├── test_distinct.test │ ├── test_except.test │ ├── test_from_substrait_basic.test │ ├── test_from_substrait_nested_types.test │ ├── test_functions.test │ ├── test_intersect.test │ ├── test_join.test │ ├── test_limit.test │ ├── test_list_type.test │ ├── test_literals.test │ ├── test_map_type.test │ ├── test_nested_expressions.test │ ├── test_spark_gateway.test │ ├── test_struct_types.test │ ├── test_substrait.test │ ├── test_substrait_enable_optimizer.test │ ├── test_substrait_extract.test │ ├── test_substrait_function_name.test │ ├── test_substrait_httpfs.test │ ├── test_substrait_in.test │ ├── test_substrait_issue_01.test │ ├── test_substrait_json.test │ ├── test_substrait_nested_types.test │ ├── test_substrait_parquet.test │ ├── test_substrait_scalar.test │ ├── test_substrait_schema_json.test │ ├── test_substrait_simple.test │ ├── test_substrait_subqueries.test │ ├── test_substrait_topn.test │ ├── test_substrait_tpcds.test │ ├── test_substrait_tpch.test │ ├── test_substrait_types.test │ ├── test_temporary_view.test │ ├── test_union.test │ └── test_virtual_table.test ├── third_party ├── google │ └── protobuf │ │ ├── LICENSE │ │ ├── any.cc │ │ ├── any.h │ │ ├── any.pb.cc │ │ ├── any.pb.h │ │ ├── any_lite.cc │ │ ├── arena.cc │ │ ├── arena.h │ │ ├── arena_impl.h │ │ ├── arenastring.cc │ │ ├── arenastring.h │ │ ├── descriptor.cc │ │ ├── descriptor.h │ │ ├── descriptor.pb.cc │ │ ├── descriptor.pb.h │ │ ├── descriptor_database.cc │ │ ├── descriptor_database.h │ │ ├── dynamic_message.cc │ │ ├── dynamic_message.h │ │ ├── empty.pb.cc │ │ ├── empty.pb.h │ │ ├── explicitly_constructed.h │ │ ├── extension_set.cc │ │ ├── extension_set.h │ │ ├── extension_set_heavy.cc │ │ ├── extension_set_inl.h │ │ ├── generated_enum_reflection.h │ │ ├── generated_enum_util.cc │ │ ├── generated_enum_util.h │ │ ├── generated_message_bases.cc │ │ ├── generated_message_bases.h │ │ ├── generated_message_reflection.cc │ │ ├── generated_message_reflection.h │ │ ├── generated_message_table_driven.cc │ │ ├── generated_message_table_driven.h │ │ ├── generated_message_table_driven_lite.cc │ │ ├── generated_message_table_driven_lite.h │ │ ├── generated_message_tctable_decl.h │ │ ├── generated_message_tctable_impl.h │ │ ├── generated_message_tctable_impl.inc │ │ ├── generated_message_util.cc │ │ ├── generated_message_util.h │ │ ├── has_bits.h │ │ ├── implicit_weak_message.cc │ │ ├── implicit_weak_message.h │ │ ├── inlined_string_field.cc │ │ ├── inlined_string_field.h │ │ ├── io │ │ ├── coded_stream.cc │ │ ├── coded_stream.h │ │ ├── io_win32.cc │ │ ├── io_win32.h │ │ ├── strtod.cc │ │ ├── strtod.h │ │ ├── tokenizer.cc │ │ ├── tokenizer.h │ │ ├── zero_copy_stream.cc │ │ ├── zero_copy_stream.h │ │ ├── zero_copy_stream_impl.cc │ │ ├── zero_copy_stream_impl.h │ │ ├── zero_copy_stream_impl_lite.cc │ │ └── zero_copy_stream_impl_lite.h │ │ ├── map.cc │ │ ├── map.h │ │ ├── map_entry.h │ │ ├── map_entry_lite.h │ │ ├── map_field.cc │ │ ├── map_field.h │ │ ├── map_field_inl.h │ │ ├── map_field_lite.h │ │ ├── map_type_handler.h │ │ ├── message.cc │ │ ├── message.h │ │ ├── message_lite.cc │ │ ├── message_lite.h │ │ ├── metadata_lite.h │ │ ├── parse_context.cc │ │ ├── parse_context.h │ │ ├── port.h │ │ ├── port_def.inc │ │ ├── port_undef.inc │ │ ├── reflection.h │ │ ├── reflection_internal.h │ │ ├── reflection_ops.cc │ │ ├── reflection_ops.h │ │ ├── repeated_field.cc │ │ ├── repeated_field.h │ │ ├── repeated_ptr_field.cc │ │ ├── repeated_ptr_field.h │ │ ├── source_context.pb.cc │ │ ├── source_context.pb.h │ │ ├── struct.pb.cc │ │ ├── struct.pb.h │ │ ├── stubs │ │ ├── bytestream.cc │ │ ├── bytestream.h │ │ ├── callback.h │ │ ├── casts.h │ │ ├── common.cc │ │ ├── common.h │ │ ├── hash.h │ │ ├── int128.cc │ │ ├── int128.h │ │ ├── logging.h │ │ ├── macros.h │ │ ├── map_util.h │ │ ├── mathutil.h │ │ ├── mutex.h │ │ ├── once.h │ │ ├── platform_macros.h │ │ ├── port.h │ │ ├── status.cc │ │ ├── status.h │ │ ├── status_macros.h │ │ ├── statusor.cc │ │ ├── statusor.h │ │ ├── stl_util.h │ │ ├── stringpiece.cc │ │ ├── stringpiece.h │ │ ├── stringprintf.cc │ │ ├── stringprintf.h │ │ ├── structurally_valid.cc │ │ ├── strutil.cc │ │ ├── strutil.h │ │ ├── substitute.cc │ │ ├── substitute.h │ │ ├── time.cc │ │ └── time.h │ │ ├── text_format.cc │ │ ├── text_format.h │ │ ├── type.pb.cc │ │ ├── type.pb.h │ │ ├── unknown_field_set.cc │ │ ├── unknown_field_set.h │ │ ├── util │ │ ├── internal │ │ │ ├── constants.h │ │ │ ├── datapiece.cc │ │ │ ├── datapiece.h │ │ │ ├── default_value_objectwriter.cc │ │ │ ├── default_value_objectwriter.h │ │ │ ├── error_listener.cc │ │ │ ├── error_listener.h │ │ │ ├── field_mask_utility.cc │ │ │ ├── field_mask_utility.h │ │ │ ├── json_escaping.cc │ │ │ ├── json_escaping.h │ │ │ ├── json_objectwriter.cc │ │ │ ├── json_objectwriter.h │ │ │ ├── json_stream_parser.cc │ │ │ ├── json_stream_parser.h │ │ │ ├── location_tracker.h │ │ │ ├── object_location_tracker.h │ │ │ ├── object_source.h │ │ │ ├── object_writer.cc │ │ │ ├── object_writer.h │ │ │ ├── proto_writer.cc │ │ │ ├── proto_writer.h │ │ │ ├── protostream_objectsource.cc │ │ │ ├── protostream_objectsource.h │ │ │ ├── protostream_objectwriter.cc │ │ │ ├── protostream_objectwriter.h │ │ │ ├── structured_objectwriter.h │ │ │ ├── type_info.cc │ │ │ ├── type_info.h │ │ │ ├── utility.cc │ │ │ └── utility.h │ │ ├── json_util.cc │ │ ├── json_util.h │ │ ├── type_resolver.h │ │ ├── type_resolver_util.cc │ │ └── type_resolver_util.h │ │ ├── wire_format.cc │ │ ├── wire_format.h │ │ ├── wire_format_lite.cc │ │ ├── wire_format_lite.h │ │ ├── wrappers.pb.cc │ │ └── wrappers.pb.h └── substrait │ ├── LICENSE │ └── substrait │ ├── algebra.pb.cc │ ├── algebra.pb.h │ ├── capabilities.pb.cc │ ├── capabilities.pb.h │ ├── extended_expression.pb.cc │ ├── extended_expression.pb.h │ ├── extensions │ ├── extensions.pb.cc │ └── extensions.pb.h │ ├── function.pb.cc │ ├── function.pb.h │ ├── parameterized_types.pb.cc │ ├── parameterized_types.pb.h │ ├── plan.pb.cc │ ├── plan.pb.h │ ├── type.pb.cc │ ├── type.pb.h │ ├── type_expressions.pb.cc │ └── type_expressions.pb.h └── vcpkg.json /.github/ISSUE_TEMPLATE/bug_report.yml: -------------------------------------------------------------------------------- 1 | name: Bug report 2 | description: Create a report to help us improve 3 | body: 4 | - type: textarea 5 | attributes: 6 | label: What happens? 7 | description: A short, clear and concise description of what the bug is. 8 | validations: 9 | required: true 10 | 11 | - type: textarea 12 | attributes: 13 | label: To Reproduce 14 | description: Steps to reproduce the behavior. Bonus points if those are only SQL queries. 15 | validations: 16 | required: true 17 | 18 | - type: markdown 19 | attributes: 20 | value: "# Environment (please complete the following information):" 21 | - type: input 22 | attributes: 23 | label: "OS:" 24 | placeholder: e.g. iOS 25 | validations: 26 | required: true 27 | - type: input 28 | attributes: 29 | label: "Substrait-Extension Version:" 30 | placeholder: e.g. 22 31 | validations: 32 | required: true 33 | - type: input 34 | attributes: 35 | label: "DuckDB Version:" 36 | placeholder: e.g. 22 37 | validations: 38 | required: true 39 | - type: input 40 | attributes: 41 | label: "DuckDB Client:" 42 | placeholder: e.g. Python 43 | validations: 44 | required: true 45 | 46 | 47 | - type: markdown 48 | attributes: 49 | value: | 50 | # Before Submitting 51 | 52 | - type: checkboxes 53 | attributes: 54 | label: Have you tried this on the latest `master` branch? 55 | description: | 56 | * **Python**: `pip install duckdb --upgrade --pre` 57 | * **R**: `install.packages('duckdb', repos=c('https://duckdb.r-universe.dev', 'https://cloud.r-project.org'))` 58 | * **Other Platforms**: You can find links to binaries [here](https://duckdb.org/docs/installation/) or compile from source. 59 | 60 | options: 61 | - label: I have 62 | required: true 63 | 64 | - type: checkboxes 65 | attributes: 66 | label: Have you tried the steps to reproduce? Do they include all relevant data and configuration? Does the issue you report still appear there? 67 | options: 68 | - label: I have 69 | required: true 70 | -------------------------------------------------------------------------------- /.github/workflows/HighPriorityIssues.yml: -------------------------------------------------------------------------------- 1 | name: Create Internal issue when the "High Priority" label is applied 2 | on: 3 | issues: 4 | types: 5 | - labeled 6 | 7 | env: 8 | GH_TOKEN: ${{ secrets.DUCKDBLABS_BOT_TOKEN }} 9 | # an event triggering this workflow is either an issue or a pull request, 10 | # hence only one of the numbers will be filled in the TITLE_PREFIX 11 | TITLE_PREFIX: "[substrait/#${{ github.event.issue.number }}]" 12 | PUBLIC_ISSUE_TITLE: ${{ github.event.issue.title }} 13 | 14 | jobs: 15 | create_or_label_issue: 16 | if: github.event.label.name == 'High Priority' 17 | runs-on: ubuntu-latest 18 | steps: 19 | - name: Get mirror issue number 20 | run: | 21 | gh issue list --repo duckdblabs/duckdb-internal --search "${TITLE_PREFIX}" --json title,number --jq ".[] | select(.title | startswith(\"$TITLE_PREFIX\")).number" > mirror_issue_number.txt 22 | echo "MIRROR_ISSUE_NUMBER=$(cat mirror_issue_number.txt)" >> $GITHUB_ENV 23 | 24 | - name: Print whether mirror issue exists 25 | run: | 26 | if [ "$MIRROR_ISSUE_NUMBER" == "" ]; then 27 | echo "Mirror issue with title prefix '$TITLE_PREFIX' does not exist yet" 28 | else 29 | echo "Mirror issue with title prefix '$TITLE_PREFIX' exists with number $MIRROR_ISSUE_NUMBER" 30 | fi 31 | 32 | - name: Create or label issue 33 | run: | 34 | if [ "$MIRROR_ISSUE_NUMBER" == "" ]; then 35 | gh issue create --repo duckdblabs/duckdb-internal --label "Substrait" --label "High Priority" --title "$TITLE_PREFIX - $PUBLIC_ISSUE_TITLE" --body "See https://github.com/duckdb/substrait/issues/${{ github.event.issue.number }}" 36 | fi 37 | -------------------------------------------------------------------------------- /.github/workflows/c_tests.yml: -------------------------------------------------------------------------------- 1 | name: C Unit tests 2 | 3 | on: [push, pull_request,repository_dispatch] 4 | 5 | defaults: 6 | run: 7 | shell: bash 8 | 9 | jobs: 10 | unitTests: 11 | name: C unit tests 12 | runs-on: macos-latest 13 | env: 14 | GEN: ninja 15 | 16 | steps: 17 | - name: Install Ninja 18 | run: brew install ninja 19 | 20 | - uses: actions/checkout@v2 21 | with: 22 | fetch-depth: 0 23 | submodules: true 24 | 25 | - name: Build Substrait with C unit test 26 | run: make release_c_unit_test 27 | 28 | - name: Run C unit tests 29 | # Disabled until iceberg can be loaded/installed again. 30 | if: false 31 | run: ./build/release/extension/substrait/test/c/test_substrait_exe 32 | -------------------------------------------------------------------------------- /.github/workflows/distribution.yml: -------------------------------------------------------------------------------- 1 | # 2 | # This workflow calls the main distribution pipeline from DuckDB to build, test and (optionally) release the extension 3 | # 4 | name: Stable Extension Distribution Pipeline 5 | on: 6 | pull_request: 7 | branches: 8 | - main 9 | paths-ignore: 10 | - '**/README.md' 11 | - 'doc/**' 12 | push: 13 | branches: 14 | - main 15 | paths-ignore: 16 | - '**/README.md' 17 | - 'doc/**' 18 | workflow_dispatch: 19 | 20 | concurrency: 21 | group: ${{ github.workflow }}-${{ github.ref }}-${{ github.head_ref || '' }}-${{ github.base_ref || '' }}-${{ github.ref != 'refs/heads/main' || github.sha }} 22 | cancel-in-progress: true 23 | 24 | jobs: 25 | duckdb-stable-build: 26 | name: Build extension binaries 27 | uses: duckdb/extension-ci-tools/.github/workflows/_extension_distribution.yml@main 28 | with: 29 | duckdb_version: bbdc794b99a41eb5da97ba9e7f09c621eee6f300 30 | ci_tools_version: cca140d4cc47f3f3e40f29b49c305bd92845771f 31 | exclude_archs: "wasm_mvp;wasm_eh;wasm_threads;windows_amd64;windows_amd64_mingw" 32 | extension_name: substrait 33 | 34 | duckdb-stable-deploy: 35 | name: Deploy extension binaries 36 | needs: duckdb-stable-build 37 | uses: duckdb/extension-ci-tools/.github/workflows/_extension_deploy.yml@main 38 | secrets: inherit 39 | with: 40 | duckdb_version: bbdc794b99a41eb5da97ba9e7f09c621eee6f300 41 | ci_tools_version: cca140d4cc47f3f3e40f29b49c305bd92845771f 42 | exclude_archs: "wasm_mvp;wasm_eh;wasm_threads;windows_amd64;windows_amd64_mingw" 43 | extension_name: substrait 44 | deploy_latest: true 45 | -------------------------------------------------------------------------------- /.github/workflows/main_distribution.yml: -------------------------------------------------------------------------------- 1 | # This workflow calls the main distribution pipeline from DuckDB to build, test and (optionally) release the extension 2 | # 3 | name: Main Extension Distribution Pipeline 4 | on: 5 | pull_request: 6 | paths-ignore: 7 | - '**/README.md' 8 | - 'doc/**' 9 | push: 10 | paths-ignore: 11 | - '**/README.md' 12 | - 'doc/**' 13 | workflow_dispatch: 14 | 15 | concurrency: 16 | group: ${{ github.workflow }}-${{ github.ref }}-${{ github.head_ref || '' }}-${{ github.base_ref || '' }}-${{ github.ref != 'refs/heads/main' || github.sha }} 17 | cancel-in-progress: true 18 | 19 | jobs: 20 | duckdb-main-build: 21 | name: Build extension binaries 22 | uses: duckdb/extension-ci-tools/.github/workflows/_extension_distribution.yml@main 23 | with: 24 | duckdb_version: bbdc794b99a41eb5da97ba9e7f09c621eee6f300 25 | ci_tools_version: cca140d4cc47f3f3e40f29b49c305bd92845771f 26 | exclude_archs: "wasm_mvp;wasm_eh;wasm_threads;windows_amd64;windows_amd64_mingw;windows_amd64_rtools" 27 | extension_name: substrait 28 | 29 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | build 2 | .idea 3 | cmake-build-debug 4 | duckdb_unittest_tempdir/ 5 | .DS_Store 6 | test/python/__pycache__/ 7 | .Rhistory 8 | test/python/test.db 9 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "duckdb"] 2 | path = duckdb 3 | url = https://github.com/duckdb/duckdb 4 | branch = main 5 | [submodule "substrait"] 6 | path = substrait 7 | url = https://github.com/substrait-io/substrait 8 | [submodule "extension-ci-tools"] 9 | path = extension-ci-tools 10 | url = https://github.com/duckdb/extension-ci-tools.git 11 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2018-2024 Stichting DuckDB Foundation 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 4 | 5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 | 7 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | PROJ_DIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST)))) 2 | 3 | all: release 4 | 5 | # Configuration of extension 6 | EXT_NAME=substrait 7 | EXT_CONFIG=${PROJ_DIR}extension_config.cmake 8 | 9 | CORE_EXTENSIONS='tpch;tpcds;json' 10 | 11 | # Set this flag during building to enable the benchmark runner 12 | ifeq (${BUILD_BENCHMARK}, 1) 13 | TOOLCHAIN_FLAGS:=${TOOLCHAIN_FLAGS} -DBUILD_BENCHMARKS=1 14 | endif 15 | 16 | # Include the Makefile from extension-ci-tools 17 | include extension-ci-tools/makefiles/duckdb_extension.Makefile 18 | 19 | pull: 20 | git submodule init 21 | git submodule update --recursive --remote 22 | 23 | # Client builds 24 | %_js: export BUILD_NODE=1 25 | debug_js: debug 26 | release_js: release 27 | 28 | %_r: export BUILD_R=1 29 | debug_r: debug 30 | release_r: release 31 | 32 | release_c_unit_test: 33 | EXT_RELEASE_FLAGS=-DSUBSTRAIT_EXTENSION_TEST_EXE=ON $(MAKE) release 34 | 35 | %_python: export BUILD_PYTHON=1 36 | %_python: export BUILD_FTS=1 37 | %_python: export BUILD_VISUALIZER=1 38 | %_python: export BUILD_TPCDS=1 39 | debug_python: debug 40 | release_python: release 41 | 42 | test_debug: debug 43 | build/debug/test/unittest "$(PROJ_DIR)test/*" 44 | 45 | # Client tests 46 | test_python: test_debug_python 47 | test_debug_python: debug_python 48 | cd test/python && python3 -m pytest 49 | 50 | test_release_python: release_python 51 | cd test/python && python3 -m pytest 52 | 53 | test_release_r: release_r 54 | cd test/r && R -f test_substrait.R 55 | 56 | test_debug_r: debug_r 57 | cd test/r && DUCKDB_R_DEBUG=1 R -f test_substrait.R 58 | 59 | format: 60 | cp ${DUCKDB_DIRECTORY}/.clang-format . 61 | find src/ -iname *.hpp -o -iname *.cpp | xargs clang-format --sort-includes=0 -style=file -i 62 | cmake-format -i CMakeLists.txt 63 | rm .clang-format 64 | 65 | update: 66 | git submodule update --remote --merge 67 | -------------------------------------------------------------------------------- /data/bug-17/test_table.parquet: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/substrait-io/duckdb-substrait-extension/ae71f52175a3696afb54909d3e5abae6aa615323/data/bug-17/test_table.parquet -------------------------------------------------------------------------------- /data/iceberg/data/.00000-0-82367eae-71e8-4631-a319-01afaf7979c8-0-00001.parquet.crc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/substrait-io/duckdb-substrait-extension/ae71f52175a3696afb54909d3e5abae6aa615323/data/iceberg/data/.00000-0-82367eae-71e8-4631-a319-01afaf7979c8-0-00001.parquet.crc -------------------------------------------------------------------------------- /data/iceberg/data/.00000-2-00930251-3748-4604-9f2c-50874f693b60-0-00001.parquet.crc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/substrait-io/duckdb-substrait-extension/ae71f52175a3696afb54909d3e5abae6aa615323/data/iceberg/data/.00000-2-00930251-3748-4604-9f2c-50874f693b60-0-00001.parquet.crc -------------------------------------------------------------------------------- /data/iceberg/data/.00001-1-82367eae-71e8-4631-a319-01afaf7979c8-0-00001.parquet.crc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/substrait-io/duckdb-substrait-extension/ae71f52175a3696afb54909d3e5abae6aa615323/data/iceberg/data/.00001-1-82367eae-71e8-4631-a319-01afaf7979c8-0-00001.parquet.crc -------------------------------------------------------------------------------- /data/iceberg/data/00000-0-82367eae-71e8-4631-a319-01afaf7979c8-0-00001.parquet: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/substrait-io/duckdb-substrait-extension/ae71f52175a3696afb54909d3e5abae6aa615323/data/iceberg/data/00000-0-82367eae-71e8-4631-a319-01afaf7979c8-0-00001.parquet -------------------------------------------------------------------------------- /data/iceberg/data/00000-2-00930251-3748-4604-9f2c-50874f693b60-0-00001.parquet: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/substrait-io/duckdb-substrait-extension/ae71f52175a3696afb54909d3e5abae6aa615323/data/iceberg/data/00000-2-00930251-3748-4604-9f2c-50874f693b60-0-00001.parquet -------------------------------------------------------------------------------- /data/iceberg/data/00001-1-82367eae-71e8-4631-a319-01afaf7979c8-0-00001.parquet: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/substrait-io/duckdb-substrait-extension/ae71f52175a3696afb54909d3e5abae6aa615323/data/iceberg/data/00001-1-82367eae-71e8-4631-a319-01afaf7979c8-0-00001.parquet -------------------------------------------------------------------------------- /data/iceberg/metadata/.5b77c0d5-7fa7-482c-b332-cddaa0d25626-m0.avro.crc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/substrait-io/duckdb-substrait-extension/ae71f52175a3696afb54909d3e5abae6aa615323/data/iceberg/metadata/.5b77c0d5-7fa7-482c-b332-cddaa0d25626-m0.avro.crc -------------------------------------------------------------------------------- /data/iceberg/metadata/.7ccac08a-42e7-4aef-b0b6-cf5365ac2df4-m0.avro.crc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/substrait-io/duckdb-substrait-extension/ae71f52175a3696afb54909d3e5abae6aa615323/data/iceberg/metadata/.7ccac08a-42e7-4aef-b0b6-cf5365ac2df4-m0.avro.crc -------------------------------------------------------------------------------- /data/iceberg/metadata/.snap-3384446302073244860-1-5b77c0d5-7fa7-482c-b332-cddaa0d25626.avro.crc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/substrait-io/duckdb-substrait-extension/ae71f52175a3696afb54909d3e5abae6aa615323/data/iceberg/metadata/.snap-3384446302073244860-1-5b77c0d5-7fa7-482c-b332-cddaa0d25626.avro.crc -------------------------------------------------------------------------------- /data/iceberg/metadata/.snap-4118182924578855064-1-7ccac08a-42e7-4aef-b0b6-cf5365ac2df4.avro.crc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/substrait-io/duckdb-substrait-extension/ae71f52175a3696afb54909d3e5abae6aa615323/data/iceberg/metadata/.snap-4118182924578855064-1-7ccac08a-42e7-4aef-b0b6-cf5365ac2df4.avro.crc -------------------------------------------------------------------------------- /data/iceberg/metadata/.v1.metadata.json.crc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/substrait-io/duckdb-substrait-extension/ae71f52175a3696afb54909d3e5abae6aa615323/data/iceberg/metadata/.v1.metadata.json.crc -------------------------------------------------------------------------------- /data/iceberg/metadata/.v2.metadata.json.crc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/substrait-io/duckdb-substrait-extension/ae71f52175a3696afb54909d3e5abae6aa615323/data/iceberg/metadata/.v2.metadata.json.crc -------------------------------------------------------------------------------- /data/iceberg/metadata/.v3.metadata.json.crc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/substrait-io/duckdb-substrait-extension/ae71f52175a3696afb54909d3e5abae6aa615323/data/iceberg/metadata/.v3.metadata.json.crc -------------------------------------------------------------------------------- /data/iceberg/metadata/.version-hint.text.crc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/substrait-io/duckdb-substrait-extension/ae71f52175a3696afb54909d3e5abae6aa615323/data/iceberg/metadata/.version-hint.text.crc -------------------------------------------------------------------------------- /data/iceberg/metadata/5b77c0d5-7fa7-482c-b332-cddaa0d25626-m0.avro: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/substrait-io/duckdb-substrait-extension/ae71f52175a3696afb54909d3e5abae6aa615323/data/iceberg/metadata/5b77c0d5-7fa7-482c-b332-cddaa0d25626-m0.avro -------------------------------------------------------------------------------- /data/iceberg/metadata/7ccac08a-42e7-4aef-b0b6-cf5365ac2df4-m0.avro: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/substrait-io/duckdb-substrait-extension/ae71f52175a3696afb54909d3e5abae6aa615323/data/iceberg/metadata/7ccac08a-42e7-4aef-b0b6-cf5365ac2df4-m0.avro -------------------------------------------------------------------------------- /data/iceberg/metadata/snap-3384446302073244860-1-5b77c0d5-7fa7-482c-b332-cddaa0d25626.avro: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/substrait-io/duckdb-substrait-extension/ae71f52175a3696afb54909d3e5abae6aa615323/data/iceberg/metadata/snap-3384446302073244860-1-5b77c0d5-7fa7-482c-b332-cddaa0d25626.avro -------------------------------------------------------------------------------- /data/iceberg/metadata/snap-4118182924578855064-1-7ccac08a-42e7-4aef-b0b6-cf5365ac2df4.avro: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/substrait-io/duckdb-substrait-extension/ae71f52175a3696afb54909d3e5abae6aa615323/data/iceberg/metadata/snap-4118182924578855064-1-7ccac08a-42e7-4aef-b0b6-cf5365ac2df4.avro -------------------------------------------------------------------------------- /data/iceberg/metadata/v1.metadata.json: -------------------------------------------------------------------------------- 1 | { 2 | "format-version" : 2, 3 | "table-uuid" : "78e034b7-424d-4de8-a08a-6ad817ad2edb", 4 | "location" : "iceberg", 5 | "last-sequence-number" : 0, 6 | "last-updated-ms" : 1737171374941, 7 | "last-column-id" : 2, 8 | "current-schema-id" : 0, 9 | "schemas" : [ { 10 | "type" : "struct", 11 | "schema-id" : 0, 12 | "fields" : [ { 13 | "id" : 1, 14 | "name" : "fruit", 15 | "required" : false, 16 | "type" : "string" 17 | }, { 18 | "id" : 2, 19 | "name" : "count", 20 | "required" : false, 21 | "type" : "decimal(10, 0)" 22 | } ] 23 | } ], 24 | "default-spec-id" : 0, 25 | "partition-specs" : [ { 26 | "spec-id" : 0, 27 | "fields" : [ ] 28 | } ], 29 | "last-partition-id" : 999, 30 | "default-sort-order-id" : 0, 31 | "sort-orders" : [ { 32 | "order-id" : 0, 33 | "fields" : [ ] 34 | } ], 35 | "properties" : { 36 | "owner" : "david", 37 | "write.parquet.compression-codec" : "zstd" 38 | }, 39 | "current-snapshot-id" : -1, 40 | "refs" : { }, 41 | "snapshots" : [ ], 42 | "statistics" : [ ], 43 | "partition-statistics" : [ ], 44 | "snapshot-log" : [ ], 45 | "metadata-log" : [ ] 46 | } -------------------------------------------------------------------------------- /data/iceberg/metadata/v2.metadata.json: -------------------------------------------------------------------------------- 1 | { 2 | "format-version" : 2, 3 | "table-uuid" : "78e034b7-424d-4de8-a08a-6ad817ad2edb", 4 | "location" : "iceberg", 5 | "last-sequence-number" : 1, 6 | "last-updated-ms" : 1737171409298, 7 | "last-column-id" : 2, 8 | "current-schema-id" : 0, 9 | "schemas" : [ { 10 | "type" : "struct", 11 | "schema-id" : 0, 12 | "fields" : [ { 13 | "id" : 1, 14 | "name" : "fruit", 15 | "required" : false, 16 | "type" : "string" 17 | }, { 18 | "id" : 2, 19 | "name" : "count", 20 | "required" : false, 21 | "type" : "decimal(10, 0)" 22 | } ] 23 | } ], 24 | "default-spec-id" : 0, 25 | "partition-specs" : [ { 26 | "spec-id" : 0, 27 | "fields" : [ ] 28 | } ], 29 | "last-partition-id" : 999, 30 | "default-sort-order-id" : 0, 31 | "sort-orders" : [ { 32 | "order-id" : 0, 33 | "fields" : [ ] 34 | } ], 35 | "properties" : { 36 | "owner" : "david", 37 | "write.parquet.compression-codec" : "zstd" 38 | }, 39 | "current-snapshot-id" : 4118182924578855064, 40 | "refs" : { 41 | "main" : { 42 | "snapshot-id" : 4118182924578855064, 43 | "type" : "branch" 44 | } 45 | }, 46 | "snapshots" : [ { 47 | "sequence-number" : 1, 48 | "snapshot-id" : 4118182924578855064, 49 | "timestamp-ms" : 1737171409298, 50 | "summary" : { 51 | "operation" : "append", 52 | "spark.app.id" : "local-1737171362701", 53 | "added-data-files" : "2", 54 | "added-records" : "2", 55 | "added-files-size" : "1388", 56 | "changed-partition-count" : "1", 57 | "total-records" : "2", 58 | "total-files-size" : "1388", 59 | "total-data-files" : "2", 60 | "total-delete-files" : "0", 61 | "total-position-deletes" : "0", 62 | "total-equality-deletes" : "0", 63 | "engine-version" : "3.5.4", 64 | "app-id" : "local-1737171362701", 65 | "engine-name" : "spark", 66 | "iceberg-version" : "Apache Iceberg 1.7.1 (commit 4a432839233f2343a9eae8255532f911f06358ef)" 67 | }, 68 | "manifest-list" : "iceberg/metadata/snap-4118182924578855064-1-7ccac08a-42e7-4aef-b0b6-cf5365ac2df4.avro", 69 | "schema-id" : 0 70 | } ], 71 | "statistics" : [ ], 72 | "partition-statistics" : [ ], 73 | "snapshot-log" : [ { 74 | "timestamp-ms" : 1737171409298, 75 | "snapshot-id" : 4118182924578855064 76 | } ], 77 | "metadata-log" : [ { 78 | "timestamp-ms" : 1737171374941, 79 | "metadata-file" : "iceberg/metadata/v1.metadata.json" 80 | } ] 81 | } -------------------------------------------------------------------------------- /data/iceberg/metadata/v3.metadata.json: -------------------------------------------------------------------------------- 1 | { 2 | "format-version" : 2, 3 | "table-uuid" : "78e034b7-424d-4de8-a08a-6ad817ad2edb", 4 | "location" : "iceberg", 5 | "last-sequence-number" : 2, 6 | "last-updated-ms" : 1737171437488, 7 | "last-column-id" : 2, 8 | "current-schema-id" : 0, 9 | "schemas" : [ { 10 | "type" : "struct", 11 | "schema-id" : 0, 12 | "fields" : [ { 13 | "id" : 1, 14 | "name" : "fruit", 15 | "required" : false, 16 | "type" : "string" 17 | }, { 18 | "id" : 2, 19 | "name" : "count", 20 | "required" : false, 21 | "type" : "decimal(10, 0)" 22 | } ] 23 | } ], 24 | "default-spec-id" : 0, 25 | "partition-specs" : [ { 26 | "spec-id" : 0, 27 | "fields" : [ ] 28 | } ], 29 | "last-partition-id" : 999, 30 | "default-sort-order-id" : 0, 31 | "sort-orders" : [ { 32 | "order-id" : 0, 33 | "fields" : [ ] 34 | } ], 35 | "properties" : { 36 | "owner" : "david", 37 | "write.parquet.compression-codec" : "zstd" 38 | }, 39 | "current-snapshot-id" : 3384446302073244860, 40 | "refs" : { 41 | "main" : { 42 | "snapshot-id" : 3384446302073244860, 43 | "type" : "branch" 44 | } 45 | }, 46 | "snapshots" : [ { 47 | "sequence-number" : 1, 48 | "snapshot-id" : 4118182924578855064, 49 | "timestamp-ms" : 1737171409298, 50 | "summary" : { 51 | "operation" : "append", 52 | "spark.app.id" : "local-1737171362701", 53 | "added-data-files" : "2", 54 | "added-records" : "2", 55 | "added-files-size" : "1388", 56 | "changed-partition-count" : "1", 57 | "total-records" : "2", 58 | "total-files-size" : "1388", 59 | "total-data-files" : "2", 60 | "total-delete-files" : "0", 61 | "total-position-deletes" : "0", 62 | "total-equality-deletes" : "0", 63 | "engine-version" : "3.5.4", 64 | "app-id" : "local-1737171362701", 65 | "engine-name" : "spark", 66 | "iceberg-version" : "Apache Iceberg 1.7.1 (commit 4a432839233f2343a9eae8255532f911f06358ef)" 67 | }, 68 | "manifest-list" : "iceberg/metadata/snap-4118182924578855064-1-7ccac08a-42e7-4aef-b0b6-cf5365ac2df4.avro", 69 | "schema-id" : 0 70 | }, { 71 | "sequence-number" : 2, 72 | "snapshot-id" : 3384446302073244860, 73 | "parent-snapshot-id" : 4118182924578855064, 74 | "timestamp-ms" : 1737171437488, 75 | "summary" : { 76 | "operation" : "append", 77 | "spark.app.id" : "local-1737171362701", 78 | "added-data-files" : "1", 79 | "added-records" : "1", 80 | "added-files-size" : "719", 81 | "changed-partition-count" : "1", 82 | "total-records" : "3", 83 | "total-files-size" : "2107", 84 | "total-data-files" : "3", 85 | "total-delete-files" : "0", 86 | "total-position-deletes" : "0", 87 | "total-equality-deletes" : "0", 88 | "engine-version" : "3.5.4", 89 | "app-id" : "local-1737171362701", 90 | "engine-name" : "spark", 91 | "iceberg-version" : "Apache Iceberg 1.7.1 (commit 4a432839233f2343a9eae8255532f911f06358ef)" 92 | }, 93 | "manifest-list" : "iceberg/metadata/snap-3384446302073244860-1-5b77c0d5-7fa7-482c-b332-cddaa0d25626.avro", 94 | "schema-id" : 0 95 | } ], 96 | "statistics" : [ ], 97 | "partition-statistics" : [ ], 98 | "snapshot-log" : [ { 99 | "timestamp-ms" : 1737171409298, 100 | "snapshot-id" : 4118182924578855064 101 | }, { 102 | "timestamp-ms" : 1737171437488, 103 | "snapshot-id" : 3384446302073244860 104 | } ], 105 | "metadata-log" : [ { 106 | "timestamp-ms" : 1737171374941, 107 | "metadata-file" : "iceberg/metadata/v1.metadata.json" 108 | }, { 109 | "timestamp-ms" : 1737171409298, 110 | "metadata-file" : "iceberg/metadata/v2.metadata.json" 111 | } ] 112 | } -------------------------------------------------------------------------------- /data/iceberg/metadata/version-hint.text: -------------------------------------------------------------------------------- 1 | 3 -------------------------------------------------------------------------------- /data/parquet-testing/glob/t1.parquet: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/substrait-io/duckdb-substrait-extension/ae71f52175a3696afb54909d3e5abae6aa615323/data/parquet-testing/glob/t1.parquet -------------------------------------------------------------------------------- /data/parquet-testing/glob/t2.parquet: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/substrait-io/duckdb-substrait-extension/ae71f52175a3696afb54909d3e5abae6aa615323/data/parquet-testing/glob/t2.parquet -------------------------------------------------------------------------------- /data/parquet-testing/lineitem-top10000.gzip.parquet: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/substrait-io/duckdb-substrait-extension/ae71f52175a3696afb54909d3e5abae6aa615323/data/parquet-testing/lineitem-top10000.gzip.parquet -------------------------------------------------------------------------------- /extension_config.cmake: -------------------------------------------------------------------------------- 1 | # This file is included by DuckDB's build system. It specifies which extension to load 2 | 3 | # Extension from this repo 4 | duckdb_extension_load(substrait 5 | SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR} 6 | INCLUDE_DIR ${CMAKE_CURRENT_LIST_DIR}/src/include 7 | LOAD_TESTS 8 | ) 9 | -------------------------------------------------------------------------------- /scripts/dependencies.R: -------------------------------------------------------------------------------- 1 | local({ 2 | pkg <- c("DBI", "callr", "DBItest", "dbplyr", "testthat", "bit64", "cpp11", "arrow", "covr", "pkgbuild", "remotes") 3 | 4 | if (.Platform$OS.type == "unix") { 5 | options(HTTPUserAgent = sprintf("R/4.1.0 R (4.1.0 %s)", paste(R.version$platform, R.version$arch, R.version$os))) 6 | install.packages(pkg, repos = "https://packagemanager.rstudio.com/all/__linux__/focal/latest") 7 | # https://github.com/r-lib/covr/pull/499 8 | remotes::install_github("r-lib/covr") 9 | } else { 10 | install.packages(pkg, repos = "https://cloud.r-project.org", pkgType = "binary") 11 | } 12 | }) 13 | -------------------------------------------------------------------------------- /scripts/generate_custom_functions.py: -------------------------------------------------------------------------------- 1 | import os 2 | from os import walk 3 | import yaml 4 | import regex 5 | 6 | 7 | 8 | def parse_function_data(functions,yaml_data,function_type): 9 | for function_data in yaml_data.get(function_type, []): 10 | function = { 11 | 'name': function_data['name'], 12 | 'impls_args': [] 13 | } 14 | 15 | for implementation in function_data.get('impls', []): 16 | args = [] 17 | for arg in implementation.get('args', []): 18 | arg_info = {'name': arg.get('name', ''), 'value': arg.get('value', '')} 19 | args.append(arg_info) 20 | 21 | function['impls_args'].append(args) 22 | 23 | functions.append(function) 24 | return functions 25 | 26 | def parse_yaml(file_path): 27 | with open(file_path, 'r') as file: 28 | yaml_data = yaml.safe_load(file) 29 | functions = [] 30 | functions = parse_function_data(functions,yaml_data,'scalar_functions') 31 | functions = parse_function_data(functions,yaml_data,'aggregate_functions') 32 | return functions 33 | 34 | def get_custom_functions(): 35 | inner_code = "" 36 | type_set = set() 37 | custom_extension_folder = os.path.join(os.path.dirname(os.path.realpath(__file__)),'..','substrait','extensions') 38 | custom_function_paths = next(walk(custom_extension_folder), (None, None, []))[2] 39 | for custom_function_path in custom_function_paths: 40 | functions = parse_yaml(os.path.join(custom_extension_folder,custom_function_path)) 41 | for function in functions: 42 | for impls_args in function["impls_args"]: 43 | type_str = "{" 44 | for args in impls_args: 45 | type_value = regex.sub(r'<[^>]*>', '', args["value"]) 46 | if (len(type_value) != 0): 47 | type_set.add(type_value) 48 | type_str += f"\"{type_value}\"," 49 | type_str = type_str[:-1] 50 | type_str += "}" 51 | function_name = function["name"] 52 | inner_code += f"\tInsertCustomFunction(\"{function_name}\", {type_str}, \"{custom_function_path}\");\n" 53 | print(type_set) 54 | return inner_code 55 | 56 | def write_custom_extension_file(custom_functions): 57 | file_path = os.path.join(os.path.dirname(os.path.realpath(__file__)),'..','src','custom_extensions_generated.cpp') 58 | header = '''#include "custom_extensions/custom_extensions.hpp" 59 | 60 | //! This class is auto-generated by scripts/geenrate_extension_initializer.py 61 | //! It depends on substrait/extensions yaml files 62 | namespace duckdb{ 63 | 64 | void SubstraitCustomFunctions::Initialize(){ 65 | ''' 66 | footer = '''} 67 | 68 | } // namespace duckdb''' 69 | 70 | # Open the file in write mode 71 | with open(file_path, 'w') as file: 72 | # Write new content to the file 73 | file.write(header) 74 | file.write(custom_functions) 75 | file.write(footer) 76 | 77 | functions = get_custom_functions() 78 | write_custom_extension_file(functions) -------------------------------------------------------------------------------- /scripts/update_substrait.py: -------------------------------------------------------------------------------- 1 | # Requires protoc 3.19.04 2 | # https://github.com/protocolbuffers/protobuf/releases/tag/v3.19.4 3 | 4 | import os 5 | import shutil 6 | from os import walk 7 | 8 | GITHUB_TAG = "7e3c1394fe6c5a0cce1c1afcc6db9731db2dfc52" # v0.64.0 9 | # Change to substrait folder 10 | sub_folder = os.path.join(os.path.dirname(os.path.realpath(__file__)),'..','third_party','substrait') 11 | os.chdir(sub_folder) 12 | 13 | 14 | # Delete Current CPP files 15 | shutil.rmtree(os.path.join(sub_folder,'substrait')) 16 | 17 | # Clone Proto Files 18 | os.system("git clone https://github.com/substrait-io/substrait git-sub") 19 | git_folder = os.path.join(sub_folder,'git-sub') 20 | 21 | # Generate Proto Files on a specific git tag 22 | os.chdir(git_folder) 23 | os.system("git checkout " + GITHUB_TAG) 24 | os.chdir(sub_folder) 25 | 26 | proto_folder = os.path.join(git_folder,'proto') 27 | substrait_proto_folder = os.path.join(proto_folder,'substrait') 28 | substrait_extensions_proto_folder = os.path.join(substrait_proto_folder,'extensions') 29 | 30 | os.mkdir("substrait") 31 | os.mkdir("substrait/extensions") 32 | 33 | # Generate all files 34 | proto_sub_list = next(walk(substrait_proto_folder), (None, None, []))[2] 35 | 36 | proto_sub_extensions = next(walk(substrait_extensions_proto_folder), (None, None, []))[2] 37 | 38 | # /usr/local/bin/protoc 39 | print("Protoc version" + os.popen('protoc --version').read()) 40 | 41 | for proto in proto_sub_list: 42 | os.system("protoc -I="+ proto_folder+ " --cpp_out="+sub_folder +" "+ os.path.join(substrait_proto_folder,proto)) 43 | 44 | for proto in proto_sub_extensions: 45 | os.system("protoc -I="+ proto_folder+ " --cpp_out="+sub_folder +" "+ os.path.join(substrait_extensions_proto_folder,proto)) 46 | 47 | # Delete Git Folder 48 | shutil.rmtree(git_folder) 49 | -------------------------------------------------------------------------------- /src/include/custom_extensions/custom_extensions.hpp: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // DuckDB 3 | // 4 | // custom_extensions/substrait_custom_extensions.hpp 5 | // 6 | // 7 | //===----------------------------------------------------------------------===// 8 | 9 | #pragma once 10 | 11 | #include "duckdb/common/types/hash.hpp" 12 | #include 13 | #include 14 | 15 | namespace duckdb { 16 | 17 | struct SubstraitCustomFunction { 18 | SubstraitCustomFunction(string name_p, vector arg_types_p) 19 | : name(std::move(name_p)), arg_types(std::move(arg_types_p)) {}; 20 | 21 | SubstraitCustomFunction() = default; 22 | bool operator==(const SubstraitCustomFunction &other) const { 23 | return name == other.name && arg_types == other.arg_types; 24 | } 25 | string GetName(); 26 | string name; 27 | vector arg_types; 28 | }; 29 | //! Here we define function extensions 30 | class SubstraitFunctionExtensions { 31 | public: 32 | SubstraitFunctionExtensions(SubstraitCustomFunction function_p, string extension_path_p) 33 | : function(std::move(function_p)), extension_path(std::move(extension_path_p)) {}; 34 | SubstraitFunctionExtensions() = default; 35 | 36 | string GetExtensionURI() const; 37 | bool IsNative() const; 38 | 39 | SubstraitCustomFunction function; 40 | string extension_path; 41 | }; 42 | 43 | struct HashSubstraitFunctions { 44 | size_t operator()(SubstraitCustomFunction const &custom_function) const noexcept { 45 | // Hash Name 46 | auto hash_name = Hash(custom_function.name.c_str()); 47 | // Hash Input Types 48 | auto &i_types = custom_function.arg_types; 49 | auto hash_type = Hash(i_types[0].c_str()); 50 | for (idx_t i = 1; i < i_types.size(); i++) { 51 | hash_type = CombineHash(hash_type, Hash(i_types[i].c_str())); 52 | } 53 | // Combine name and inputs 54 | return CombineHash(hash_name, hash_type); 55 | } 56 | }; 57 | 58 | struct HashSubstraitFunctionsName { 59 | size_t operator()(SubstraitCustomFunction const &custom_function) const noexcept { 60 | // Hash Name 61 | return Hash(custom_function.name.c_str()); 62 | } 63 | }; 64 | 65 | class SubstraitCustomFunctions { 66 | public: 67 | SubstraitCustomFunctions(); 68 | SubstraitFunctionExtensions Get(const string &name, const vector &types) const; 69 | static vector GetTypes(const vector &types); 70 | void Initialize(); 71 | 72 | private: 73 | // For Regular Functions 74 | std::unordered_map custom_functions; 75 | // For * Functions 76 | std::unordered_map 77 | any_arg_functions; 78 | // For ? Functions 79 | // When we have an argument ending with ? it means this argument can repeat many times 80 | std::unordered_map many_arg_functions; 81 | 82 | void InsertCustomFunction(string name_p, vector types_p, string file_path); 83 | void InsertAllFunctions(const vector> &all_types, vector &indices, int depth, string &name_p, 84 | string &file_path); 85 | }; 86 | 87 | } // namespace duckdb -------------------------------------------------------------------------------- /src/include/substrait_extension.hpp: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // DuckDB 3 | // 4 | // substrait-extension.hpp 5 | // 6 | // 7 | //===----------------------------------------------------------------------===// 8 | 9 | #pragma once 10 | 11 | #include "duckdb.hpp" 12 | 13 | namespace duckdb { 14 | 15 | class SubstraitExtension : public Extension { 16 | public: 17 | void Load(DuckDB &db) override; 18 | std::string Name() override; 19 | }; 20 | 21 | } // namespace duckdb 22 | -------------------------------------------------------------------------------- /test/c/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.5...3.29) 2 | set(TARGET_NAME substrait_c_test) 3 | project(${TARGET_NAME}) 4 | 5 | set (CMAKE_CXX_STANDARD 11) 6 | 7 | include_directories(../../duckdb/src/include) 8 | include_directories(../../duckdb/test/include) 9 | include_directories(../../duckdb/third_party/catch) 10 | 11 | set(ALL_SOURCES test_substrait_c_api.cpp test_substrait_c_utils.cpp test_projection.cpp) 12 | 13 | 14 | add_library_unity(test_substrait OBJECT ${ALL_SOURCES}) 15 | set(ALL_OBJECT_FILES 16 | ${ALL_OBJECT_FILES} $ 17 | PARENT_SCOPE) 18 | 19 | option(SUBSTRAIT_EXTENSION_TEST_EXE "Build the optional test executable" OFF) 20 | if (SUBSTRAIT_EXTENSION_TEST_EXE) 21 | # Add an executable target with main.cpp 22 | add_executable(test_substrait_exe $ main.cpp) 23 | # Link the executable with necessary libraries 24 | target_link_libraries(test_substrait_exe duckdb substrait_extension test_helpers) 25 | endif() 26 | -------------------------------------------------------------------------------- /test/c/main.cpp: -------------------------------------------------------------------------------- 1 | #define CATCH_CONFIG_RUNNER 2 | #include "catch.hpp" 3 | 4 | int main(int argc, char* argv[]) { 5 | // Call Catch2's session to run tests 6 | return Catch::Session().run(argc, argv); 7 | } 8 | -------------------------------------------------------------------------------- /test/c/test_substrait_c_utils.cpp: -------------------------------------------------------------------------------- 1 | #include "test_helpers.hpp" 2 | #include "test_substrait_c_utils.hpp" 3 | 4 | using namespace duckdb; 5 | using namespace std; 6 | 7 | 8 | string GetSubstrait(Connection &con,const string &query) { 9 | duckdb::vector params; 10 | params.emplace_back(query); 11 | auto result = con.TableFunction("get_substrait", params)->Execute(); 12 | auto protobuf = result->FetchRaw()->GetValue(0, 0); 13 | return protobuf.GetValueUnsafe().GetString(); 14 | } 15 | 16 | string GetSubstraitJSON(Connection &con,const string &query) { 17 | duckdb::vector params; 18 | params.emplace_back(query); 19 | auto result = con.TableFunction("get_substrait_json", params)->Execute(); 20 | auto protobuf = result->FetchRaw()->GetValue(0, 0); 21 | return protobuf.GetValueUnsafe().GetString(); 22 | } 23 | 24 | duckdb::unique_ptr FromSubstrait(Connection &con, const string &proto) { 25 | duckdb::vector params; 26 | params.emplace_back(Value::BLOB_RAW(proto)); 27 | return con.TableFunction("from_substrait", params)->Execute(); 28 | } 29 | 30 | duckdb::unique_ptr FromSubstraitJSON(Connection &con, const string &proto) { 31 | duckdb::vector params; 32 | params.emplace_back(proto); 33 | return con.TableFunction("from_substrait_json", params)->Execute(); 34 | } 35 | 36 | duckdb::unique_ptr ExecuteViaSubstrait(Connection &con, const string &sql) { 37 | auto proto = GetSubstrait(con, sql); 38 | return FromSubstrait(con,proto); 39 | } 40 | 41 | duckdb::unique_ptr ExecuteViaSubstraitJSON(Connection &con, const string &sql) { 42 | auto json_str = GetSubstraitJSON(con,sql); 43 | return FromSubstraitJSON(con,json_str); 44 | } 45 | 46 | void CreateEmployeeTable(Connection& con) { 47 | REQUIRE_NO_FAIL(con.Query("CREATE TABLE employees (" 48 | "employee_id INTEGER PRIMARY KEY, " 49 | "name VARCHAR(100), " 50 | "department_id INTEGER, " 51 | "salary DECIMAL(10, 2))")); 52 | 53 | REQUIRE_NO_FAIL(con.Query("INSERT INTO employees VALUES " 54 | "(1, 'John Doe', 1, 120000), " 55 | "(2, 'Jane Smith', 2, 80000), " 56 | "(3, 'Alice Johnson', 1, 50000), " 57 | "(4, 'Bob Brown', 3, 95000), " 58 | "(5, 'Charlie Black', 2, 60000)")); 59 | } 60 | 61 | void CreatePartTimeEmployeeTable(Connection& con) { 62 | REQUIRE_NO_FAIL(con.Query("CREATE TABLE part_time_employees (" 63 | "id INTEGER PRIMARY KEY, " 64 | "name VARCHAR(100), " 65 | "department_id INTEGER, " 66 | "hourly_rate DECIMAL(10, 2))")); 67 | 68 | REQUIRE_NO_FAIL(con.Query("INSERT INTO part_time_employees VALUES " 69 | "(6, 'David White', 1, 30000), " 70 | "(7, 'Eve Green', 2, 40000)")); 71 | } 72 | 73 | void CreateDepartmentsTable(Connection& con) { 74 | REQUIRE_NO_FAIL(con.Query("CREATE TABLE departments (department_id INTEGER PRIMARY KEY, department_name VARCHAR(100))")); 75 | 76 | REQUIRE_NO_FAIL(con.Query("INSERT INTO departments VALUES " 77 | "(1, 'HR'), " 78 | "(2, 'Engineering'), " 79 | "(3, 'Finance')")); 80 | } 81 | -------------------------------------------------------------------------------- /test/c/test_substrait_c_utils.hpp: -------------------------------------------------------------------------------- 1 | #ifndef TEST_SUBSTRAIT_C_UTILS_HPP 2 | #define TEST_SUBSTRAIT_C_UTILS_HPP 3 | 4 | #include "duckdb.hpp" 5 | #include "duckdb/main/connection_manager.hpp" 6 | 7 | using namespace duckdb; 8 | void CreateEmployeeTable(Connection& con); 9 | void CreatePartTimeEmployeeTable(Connection& con); 10 | void CreateDepartmentsTable(Connection& con); 11 | 12 | duckdb::unique_ptr ExecuteViaSubstraitJSON(Connection &con, const std::string &query); 13 | duckdb::unique_ptr ExecuteViaSubstrait(Connection &con, const std::string &query); 14 | string GetSubstrait(Connection &con,const string &query); 15 | string GetSubstraitJSON(Connection &con,const string &query); 16 | duckdb::unique_ptr FromSubstrait(Connection &con, const string &proto); 17 | duckdb::unique_ptr FromSubstraitJSON(Connection &con, const string &proto); 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /test/sql/test_between.test: -------------------------------------------------------------------------------- 1 | # name: test/sql/test_between.test 2 | # description: Test BETWEEN comparison 3 | # group: [sql] 4 | 5 | require substrait 6 | 7 | statement ok 8 | PRAGMA enable_verification 9 | 10 | statement ok 11 | create table t as select * from range(100) as t(x) 12 | 13 | statement ok 14 | CALL get_substrait('select * from t where x BETWEEN 4 AND 6;', enable_optimizer = false ); 15 | -------------------------------------------------------------------------------- /test/sql/test_custom_function.test: -------------------------------------------------------------------------------- 1 | # name: test/sql/test_custom_function.test 2 | # description: Test that using custom functions gives the correct extension info 3 | # group: [sql] 4 | 5 | require substrait 6 | 7 | statement ok 8 | PRAGMA enable_verification 9 | 10 | statement ok 11 | create table t (a double) 12 | 13 | statement ok 14 | insert into t values (1) 15 | 16 | # This should emit extension information 17 | query I 18 | CALL get_substrait_json('select sin(a) from t') 19 | ---- 20 | :.*https://github.com/substrait-io/substrait/blob/main/extensions/functions_arithmetic.yaml.* 21 | 22 | query I 23 | CALL get_substrait_json('select sin(a) from t') 24 | ---- 25 | :.*sin:fp64.* 26 | 27 | # Test one with two arguments 28 | query I 29 | CALL get_substrait_json('select atan2(a,a) from t') 30 | ---- 31 | :.*atan2:fp64_fp64.* 32 | 33 | # Test string 34 | statement ok 35 | create table t_2 (a varchar) 36 | 37 | statement ok 38 | insert into t_2 values (':.*https://github.com/substrait-io/substrait/blob/main/extensions/functions_string.yaml.* 44 | 45 | query I 46 | CALL get_substrait_json('select trim(a, ''<'') from t_2') 47 | ---- 48 | :.*trim:string_string.* 49 | 50 | # Test native functionality does not return extensions or arguments 51 | 52 | query I 53 | CALL get_substrait_json('select sum(a) from t') 54 | ---- 55 | :.*https://github.com/substrait-io/substrait/blob/main/extensions/functions_arithmetic.yaml.* 56 | 57 | query I 58 | CALL get_substrait_json('select sum(a) from t') 59 | ---- 60 | :.*"sum:fp64".* 61 | 62 | # Test mix 63 | 64 | query I 65 | CALL get_substrait_json('select a+a, sin(a) from t') 66 | ---- 67 | :.*https://github.com/substrait-io/substrait/blob/main/extensions/functions_arithmetic.yaml.* 68 | 69 | query I 70 | CALL get_substrait_json('select sin(t.a), trim(t_2.a, ''<'') from t,t_2') 71 | ---- 72 | :.*https://github.com/substrait-io/substrait/blob/main/extensions/functions_arithmetic.yaml.* 73 | 74 | query I 75 | CALL get_substrait_json('select sin(t.a), trim(t_2.a, ''<'') from t,t_2') 76 | ---- 77 | :.*https://github.com/substrait-io/substrait/blob/main/extensions/functions_string.yaml.* 78 | 79 | 80 | -------------------------------------------------------------------------------- /test/sql/test_direct_scan.test: -------------------------------------------------------------------------------- 1 | # name: test/sql/test_direct_scan.test 2 | # description: Test that a direct table scan works 3 | # group: [sql] 4 | 5 | require substrait 6 | 7 | statement ok 8 | PRAGMA enable_verification 9 | 10 | statement ok 11 | create table users (user_id varchar, name varchar, paid_for_service bool); 12 | 13 | statement ok 14 | insert into users values ('1', 'Pedro', false); 15 | 16 | statement ok 17 | CALL get_substrait('FROM users') 18 | 19 | query III 20 | CALL from_substrait_json('{ 21 | "relations": [ 22 | { 23 | "root": { 24 | "input": { 25 | "read": { 26 | "common": { 27 | "direct": {} 28 | }, 29 | "baseSchema": { 30 | "names": [ 31 | "user_id", 32 | "name", 33 | "paid_for_service" 34 | ], 35 | "struct": { 36 | "types": [ 37 | { 38 | "string": { 39 | "nullability": "NULLABILITY_NULLABLE" 40 | } 41 | }, 42 | { 43 | "string": { 44 | "nullability": "NULLABILITY_NULLABLE" 45 | } 46 | }, 47 | { 48 | "bool": { 49 | "nullability": "NULLABILITY_NULLABLE" 50 | } 51 | } 52 | ], 53 | "nullability": "NULLABILITY_REQUIRED" 54 | } 55 | }, 56 | "namedTable": { 57 | "names": [ 58 | "users" 59 | ] 60 | } 61 | } 62 | }, 63 | "names": [ 64 | "user_id", 65 | "name", 66 | "paid_for_service" 67 | ] 68 | } 69 | } 70 | ], 71 | "version": { 72 | "minorNumber": 52, 73 | "producer": "spark-substrait-gateway" 74 | } 75 | } 76 | ') 77 | ---- 78 | 1 Pedro false -------------------------------------------------------------------------------- /test/sql/test_distinct.test: -------------------------------------------------------------------------------- 1 | # name: test/sql/test_distinct.test 2 | # description: Test the Count Distinct operation 3 | # group: [sql] 4 | 5 | require substrait 6 | 7 | statement ok 8 | PRAGMA enable_verification 9 | 10 | statement ok 11 | create table t (a integer) 12 | 13 | statement ok 14 | insert into t values (0),(1),(3),(0),(2),(1),(5),(NULL),(1),(5),(NULL),(1000); 15 | 16 | statement ok 17 | CALL get_substrait('select count(distinct a) from t') -------------------------------------------------------------------------------- /test/sql/test_except.test: -------------------------------------------------------------------------------- 1 | # name: test/sql/test_except.test 2 | # description: Test the EXCEPT set operation 3 | # group: [sql] 4 | 5 | require substrait 6 | 7 | statement ok 8 | PRAGMA enable_verification 9 | 10 | # Create two tables to use in the EXCEPT 11 | statement ok 12 | create table tbl1 as select * from (VALUES 13 | (1, 2, 3, 4), 14 | (2, 3, 4, 5) 15 | ) as tbl(A, B, C, D) 16 | 17 | statement ok 18 | create table tbl2 as select * from (VALUES 19 | (2, 3, 4, 5), 20 | (3, 4, 5, 6) 21 | ) as tbl(B, C, D, A) 22 | 23 | statement ok 24 | CALL get_substrait('select * from tbl1 EXCEPT (select * from tbl2)') 25 | -------------------------------------------------------------------------------- /test/sql/test_from_substrait_basic.test: -------------------------------------------------------------------------------- 1 | # name: test/sql/test_from_substrait_basic.test 2 | # description: Test from_substrait basic functionality 3 | # group: [sql] 4 | 5 | require substrait 6 | 7 | statement ok 8 | PRAGMA enable_verification 9 | 10 | statement ok 11 | CREATE TABLE basic_test (id INTEGER, name VARCHAR, age INTEGER); 12 | 13 | statement ok 14 | INSERT INTO basic_test VALUES 15 | (1, 'Alice', 30), 16 | (2, 'Bob', 25), 17 | (3, 'Charlie', 35); 18 | 19 | # First get a substrait plan for later comparison 20 | statement ok 21 | CALL get_substrait('SELECT * FROM basic_test') 22 | 23 | # Test using JSON format with from_substrait_json 24 | # This tests a simple query returning all rows 25 | query III 26 | CALL from_substrait_json('{ 27 | "version": { 28 | "minorNumber": 19, 29 | "producer": "DuckDB" 30 | }, 31 | "relations": [{ 32 | "root": { 33 | "input": { 34 | "read": { 35 | "baseSchema": { 36 | "names": ["id", "name", "age"], 37 | "struct": { 38 | "types": [ 39 | {"i32": {"nullability": "NULLABILITY_REQUIRED"}}, 40 | {"varchar": {"nullability": "NULLABILITY_REQUIRED"}}, 41 | {"i32": {"nullability": "NULLABILITY_REQUIRED"}} 42 | ], 43 | "nullability": "NULLABILITY_REQUIRED" 44 | } 45 | }, 46 | "namedTable": { 47 | "names": ["basic_test"] 48 | } 49 | } 50 | }, 51 | "names": ["id", "name", "age"] 52 | } 53 | }] 54 | }') 55 | ---- 56 | 1 Alice 30 57 | 2 Bob 25 58 | 3 Charlie 35 59 | 60 | # Test with a filter 61 | query III 62 | CALL from_substrait_json('{ 63 | "version": { 64 | "minorNumber": 19, 65 | "producer": "DuckDB" 66 | }, 67 | "relations": [{ 68 | "root": { 69 | "input": { 70 | "filter": { 71 | "input": { 72 | "read": { 73 | "baseSchema": { 74 | "names": ["id", "name", "age"], 75 | "struct": { 76 | "types": [ 77 | {"i32": {"nullability": "NULLABILITY_REQUIRED"}}, 78 | {"varchar": {"nullability": "NULLABILITY_REQUIRED"}}, 79 | {"i32": {"nullability": "NULLABILITY_REQUIRED"}} 80 | ], 81 | "nullability": "NULLABILITY_REQUIRED" 82 | } 83 | }, 84 | "namedTable": { 85 | "names": ["basic_test"] 86 | } 87 | } 88 | }, 89 | "condition": { 90 | "scalarFunction": { 91 | "functionReference": 1, 92 | "arguments": [ 93 | {"value": {"selection": {"directReference": {"structField": {"field": 2}}, "rootReference": {}}}}, 94 | {"value": {"literal": {"i32": 25, "nullable": false}}} 95 | ], 96 | "outputType": {"bool": {"nullability": "NULLABILITY_REQUIRED"}} 97 | } 98 | } 99 | } 100 | }, 101 | "names": ["id", "name", "age"] 102 | } 103 | }], 104 | "extensions": [ 105 | {"extensionFunction": {"extensionUriReference": 0, "functionAnchor": 1, "name": "gt"}} 106 | ], 107 | "extensionUris": [ 108 | {"extensionUriAnchor": 0, "uri": "https://github.com/substrait-io/substrait/blob/main/extensions/functions_comparison.yaml"} 109 | ] 110 | }') 111 | ---- 112 | 1 Alice 30 113 | 3 Charlie 35 114 | 115 | # Test with direct SQL for comparison 116 | query III 117 | SELECT * FROM basic_test WHERE age > 28 ORDER BY id 118 | ---- 119 | 1 Alice 30 120 | 3 Charlie 35 121 | 122 | statement ok 123 | DROP TABLE basic_test; 124 | -------------------------------------------------------------------------------- /test/sql/test_functions.test: -------------------------------------------------------------------------------- 1 | # name: test/sql/test_functions.test 2 | # description: Test functions roundtrip 3 | # group: [sql] 4 | 5 | require substrait 6 | 7 | statement ok 8 | PRAGMA enable_verification 9 | 10 | statement ok 11 | create table t as select 1 as a ,2 as b; 12 | 13 | # bitwise_and 14 | statement ok 15 | CALL get_substrait('select a & b from t', strict = true) 16 | 17 | # bitwise_or 18 | statement ok 19 | CALL get_substrait('select a | b from t', strict = true) 20 | 21 | # bitwise_xor 22 | statement ok 23 | CALL get_substrait('select xor(a,b) from t', strict = true) 24 | 25 | # strlen gets transformed to octet_length 26 | statement ok 27 | CALL get_substrait('select strlen(a::varchar) from t', strict = true) 28 | 29 | # coalesce 30 | statement ok 31 | CALL get_substrait('select coalesce(a) from t', strict = true) 32 | 33 | # acosh 34 | # asinh 35 | # atanh 36 | # cosh 37 | # sinh 38 | # tanh 39 | statement ok 40 | CALL get_substrait('select acosh(a),asinh(a),atanh(a),cosh(a),sinh(a),tanh(a) from t', strict = true) -------------------------------------------------------------------------------- /test/sql/test_intersect.test: -------------------------------------------------------------------------------- 1 | # name: test/sql/test_intersect.test 2 | # description: Test the INTERSECT set operation 3 | # group: [sql] 4 | 5 | require substrait 6 | 7 | statement ok 8 | PRAGMA enable_verification 9 | 10 | # Create two tables to use in the INTERSECT 11 | statement ok 12 | create table tbl1 as select * from (VALUES 13 | (1, 2, 3, 4), 14 | (2, 3, 4, 5) 15 | ) as tbl(A, B, C, D) 16 | 17 | statement ok 18 | create table tbl2 as select * from (VALUES 19 | (2, 3, 4, 5), 20 | (3, 4, 5, 6) 21 | ) as tbl(B, C, D, A) 22 | 23 | statement ok 24 | CALL get_substrait('select * from tbl1 INTERSECT (select * from tbl2)') 25 | -------------------------------------------------------------------------------- /test/sql/test_join.test: -------------------------------------------------------------------------------- 1 | # name: test/sql/test_join.test 2 | # description: Test Join operators 3 | # group: [sql] 4 | 5 | require substrait 6 | 7 | statement ok 8 | PRAGMA enable_verification 9 | 10 | statement ok 11 | CREATE table customer as select range c_custkey, range::VARCHAR c_name from range(10000); 12 | 13 | # Test Full outer join 14 | statement ok 15 | CALL get_substrait(' 16 | WITH raw_data as (SELECT * from customer), 17 | cte1 as (SELECT c_custkey as join_custkey, c_name from raw_data where c_custkey = 800), 18 | cte2 as (SELECT c_custkey as other_custkey, c_name from raw_data where c_custkey = 900) 19 | select * from cte1 full join cte2 on join_custkey = other_custkey; 20 | '); -------------------------------------------------------------------------------- /test/sql/test_limit.test: -------------------------------------------------------------------------------- 1 | # name: test/sql/test_limit.test 2 | # description: Test limit and offset operations 3 | # group: [sql] 4 | 5 | require substrait 6 | 7 | statement ok 8 | PRAGMA enable_verification 9 | 10 | statement ok 11 | create table t as FROM range(10); 12 | 13 | statement ok 14 | CALL get_substrait('select * from t limit 5'); 15 | 16 | statement ok 17 | CALL get_substrait('select * from t offset 1'); 18 | 19 | statement ok 20 | CALL get_substrait('select * from t offset 1 limit 5'); 21 | 22 | -------------------------------------------------------------------------------- /test/sql/test_list_type.test: -------------------------------------------------------------------------------- 1 | # name: test/sql/test_list_type.test 2 | # description: Test LIST type support in substrait extension 3 | # group: [sql] 4 | 5 | require substrait 6 | 7 | statement ok 8 | PRAGMA enable_verification 9 | 10 | statement ok 11 | CREATE TABLE list_test ( 12 | id INTEGER, 13 | name VARCHAR, 14 | tags VARCHAR[] 15 | ); 16 | 17 | statement ok 18 | INSERT INTO list_test VALUES 19 | (1, 'Alice', ['tag1', 'tag2', 'tag3']), 20 | (2, 'Bob', ['tag1', 'tag4']), 21 | (3, 'Charlie', ['tag2', 'tag5', 'tag6']); 22 | 23 | statement ok 24 | CALL get_substrait('SELECT id, name, tags FROM list_test'); 25 | 26 | statement ok 27 | CALL get_substrait('SELECT id, name, tags[1] FROM list_test'); 28 | 29 | statement ok 30 | CALL get_substrait('SELECT id, name FROM list_test WHERE tags[1] = ''tag1'''); 31 | 32 | statement ok 33 | CREATE TABLE complex_list_test ( 34 | id INTEGER, 35 | numbers INTEGER[], 36 | nested VARCHAR[][] 37 | ); 38 | 39 | statement ok 40 | INSERT INTO complex_list_test VALUES 41 | (1, [1, 2, 3], [['a', 'b'], ['c', 'd']]), 42 | (2, [4, 5, 6], [['e', 'f'], ['g', 'h']]); 43 | 44 | statement ok 45 | CALL get_substrait('SELECT id, numbers, nested FROM complex_list_test'); 46 | 47 | statement ok 48 | DROP TABLE complex_list_test; 49 | 50 | statement ok 51 | DROP TABLE list_test; 52 | -------------------------------------------------------------------------------- /test/sql/test_map_type.test: -------------------------------------------------------------------------------- 1 | # name: test/sql/test_map_type.test 2 | # description: Test MAP type support in substrait extension 3 | # group: [sql] 4 | 5 | require substrait 6 | 7 | statement ok 8 | PRAGMA enable_verification 9 | 10 | statement ok 11 | CREATE TABLE map_test ( 12 | id INTEGER, 13 | name VARCHAR, 14 | properties MAP(VARCHAR, VARCHAR) 15 | ); 16 | 17 | statement ok 18 | INSERT INTO map_test VALUES 19 | (1, 'Alice', MAP {'color': 'red', 'size': 'small'}), 20 | (2, 'Bob', MAP {'color': 'blue', 'size': 'medium'}), 21 | (3, 'Charlie', MAP {'color': 'green', 'size': 'large'}); 22 | 23 | statement ok 24 | CALL get_substrait('SELECT id, name, properties FROM map_test'); 25 | 26 | statement ok 27 | CALL get_substrait('SELECT id, name, properties[''color''] FROM map_test'); 28 | 29 | statement ok 30 | CALL get_substrait('SELECT id, name FROM map_test WHERE properties[''color''] = ''blue'''); 31 | 32 | statement ok 33 | CREATE VIEW map_view AS SELECT id, properties FROM map_test; 34 | 35 | statement ok 36 | CALL get_substrait('SELECT * FROM map_view'); 37 | 38 | statement ok 39 | DROP VIEW map_view; 40 | 41 | statement ok 42 | DROP TABLE map_test; 43 | -------------------------------------------------------------------------------- /test/sql/test_struct_types.test: -------------------------------------------------------------------------------- 1 | # name: test/sql/test_struct_types 2 | # description: Test for struct types, specially that they can alter the schema and root names. 3 | # group: [substrait] 4 | 5 | require substrait 6 | 7 | require parquet 8 | 9 | statement ok 10 | PRAGMA enable_verification 11 | 12 | query I 13 | CALL get_substrait_json('select * from parquet_scan(''data/bug-17/test_table.parquet'') ') 14 | ---- 15 | {"relations":[{"root":{"input":{"read":{"baseSchema":{"names":["r","a","b"],"struct":{"types":[{"struct":{"types":[{"i64":{"nullability":"NULLABILITY_NULLABLE"}},{"string":{"nullability":"NULLABILITY_NULLABLE"}}],"nullability":"NULLABILITY_NULLABLE"}}],"nullability":"NULLABILITY_REQUIRED"}},"projection":{"select":{"structItems":[{}]},"maintainSingularStruct":true},"localFiles":{"items":[{"uriFile":"data/bug-17/test_table.parquet","parquet":{}}]}}},"names":["r","a","b"]}}],"version":{"minorNumber":53,"producer":"DuckDB"}} 16 | 17 | 18 | query I 19 | CALL from_substrait_json('{"relations":[{"root":{"input":{"read":{"baseSchema":{"names":["r"],"struct":{"types":[{"struct":{"types":[{"i64":{"nullability":"NULLABILITY_NULLABLE"}},{"string":{"nullability":"NULLABILITY_NULLABLE"}}],"nullability":"NULLABILITY_NULLABLE"}}],"nullability":"NULLABILITY_REQUIRED"}},"projection":{"select":{"structItems":[{}]},"maintainSingularStruct":true},"localFiles":{"items":[{"uriFile":"data/bug-17/test_table.parquet","parquet":{}}]}}},"names":["r"]}}],"version":{"minorNumber":48,"producer":"DuckDB"}}') 20 | ---- 21 | {'a': 1, 'b': b} 22 | 23 | statement ok 24 | CALL get_substrait ('select r from parquet_scan(''data/bug-17/test_table.parquet'') ') 25 | 26 | statement ok 27 | CALL get_substrait ('select r.a from parquet_scan(''data/bug-17/test_table.parquet'') ') 28 | 29 | statement ok 30 | CALL get_substrait ('select r.b from parquet_scan(''data/bug-17/test_table.parquet'') ') 31 | 32 | statement ok 33 | CALL get_substrait ('select r.b, r.a from parquet_scan(''data/bug-17/test_table.parquet'') ') 34 | 35 | statement ok 36 | create table mytesttable as from parquet_scan('data/bug-17/test_table.parquet'); 37 | 38 | query I 39 | CALL get_substrait_json('select * from mytesttable ') 40 | ---- 41 | {"relations":[{"root":{"input":{"read":{"baseSchema":{"names":["r","a","b"],"struct":{"types":[{"struct":{"types":[{"i64":{"nullability":"NULLABILITY_NULLABLE"}},{"string":{"nullability":"NULLABILITY_NULLABLE"}}],"nullability":"NULLABILITY_NULLABLE"}}],"nullability":"NULLABILITY_REQUIRED"}},"projection":{"select":{"structItems":[{}]},"maintainSingularStruct":true},"namedTable":{"names":["mytesttable"]}}},"names":["r","a","b"]}}],"version":{"minorNumber":53,"producer":"DuckDB"}} 42 | 43 | statement ok 44 | CALL get_substrait ('select r from mytesttable ') 45 | 46 | statement ok 47 | CALL get_substrait ('select r.a from mytesttable ') 48 | 49 | statement ok 50 | CALL get_substrait ('select r.b from mytesttable ') 51 | 52 | statement ok 53 | CALL get_substrait ('select r.b, r.a from mytesttable ') -------------------------------------------------------------------------------- /test/sql/test_substrait.test: -------------------------------------------------------------------------------- 1 | # name: test/sql/test_substrait.test 2 | # description: Test get_substrait and from_substrait basic functionality 3 | # group: [sql] 4 | 5 | require substrait 6 | 7 | statement ok 8 | PRAGMA enable_verification 9 | 10 | statement ok 11 | CREATE TABLE crossfit (exercise text,dificulty_level int); 12 | 13 | statement ok 14 | CREATE TABLE integers (i integer) 15 | 16 | statement ok 17 | insert into crossfit values ('Push Ups', 3), ('Pull Ups', 5) , ('Push Jerk', 7), ('Bar Muscle Up', 10); 18 | 19 | query I 20 | CALL from_substrait('\x12\x09\x1A\x07\x10\x01\x1A\x03lte\x12\x11\x1A\x0F\x10\x02\x1A\x0Bis_not_null\x12\x09\x1A\x07\x10\x03\x1A\x03and\x12\x0B\x1A\x09\x10\x04\x1A\x05count\x1A\xC8\x01\x12\xC5\x01\x0A\xB8\x01:\xB5\x01\x0A\x05\x12\x03\x0A\x01\x01\x12\xA1\x01\x22\x9E\x01\x12\x8D\x01\x0A\x8A\x01\x12,\x0A\x08exercise\x0A\x0Fdificulty_level\x12\x0F\x0A\x07\xB2\x01\x04\x08\x0D\x18\x01\x0A\x02*\x00\x18\x02\x1AF\x1AD\x08\x03\x1A\x04\x0A\x02\x10\x01\x22\x20\x1A\x1E\x1A\x1C\x08\x01\x1A\x02*\x00\x22\x0C\x1A\x0A\x12\x08\x0A\x04\x12\x02\x08\x01\x22\x00\x22\x06\x1A\x04\x0A\x02(\x05\x22\x18\x1A\x16\x1A\x14\x08\x02\x1A\x02*\x00\x22\x0C\x1A\x0A\x12\x08\x0A\x04\x12\x02\x08\x01\x22\x00\x22\x06\x0A\x02\x0A\x00\x10\x01:\x0A\x0A\x08crossfit\x1A\x00\x22\x0A\x0A\x08\x08\x04*\x04:\x02\x10\x01\x1A\x08\x12\x06\x0A\x02\x12\x00\x22\x00\x12\x08exercise2\x0A\x10\x18*\x06DuckDB'::BLOB) 21 | ---- 22 | 2 23 | 24 | # Query with multiple columns 25 | query II 26 | CALL from_substrait('\x1Ag\x12e\x0AH\x0AF\x12,\x0A\x08exercise\x0A\x0Fdificulty_level\x12\x0F\x0A\x07\xB2\x01\x04\x08\x0D\x18\x01\x0A\x02*\x00\x18\x02\x22\x0A\x0A\x06\x0A\x00\x0A\x02\x08\x01\x10\x01:\x0A\x0A\x08crossfit\x12\x08exercise\x12\x0Fdificulty_level2\x0A\x10\x18*\x06DuckDB'::BLOB) 27 | ---- 28 | Push Ups 3 29 | Pull Ups 5 30 | Push Jerk 7 31 | Bar Muscle Up 10 32 | 33 | 34 | # Should fail with empty 35 | statement error 36 | CALL get_substrait() 37 | ---- 38 | No function matches the given name and argument types 'get_substrait()' 39 | 40 | statement error 41 | CALL get_substrait_json() 42 | ---- 43 | No function matches the given name and argument types 'get_substrait_json()' 44 | 45 | statement error 46 | CALL from_substrait() 47 | ---- 48 | No function matches the given name and argument types 'from_substrait()' 49 | 50 | # Should fail with NULL 51 | statement error 52 | CALL get_substrait(NULL) 53 | ---- 54 | syntax error at or near "NULL" 55 | 56 | statement error 57 | CALL get_substrait_json(NULL) 58 | ---- 59 | syntax error at or near "NULL" 60 | 61 | statement error 62 | CALL from_substrait(NULL) 63 | ---- 64 | from_substrait cannot be called with a NULL parameter 65 | 66 | # Should fail with Invalid Query 67 | statement error 68 | CALL get_substrait('select bla from t') 69 | ---- 70 | Catalog Error: Table with name t does not exist! 71 | 72 | statement error 73 | CALL get_substrait_json('select bla from t') 74 | ---- 75 | Catalog Error: Table with name t does not exist! 76 | 77 | #Shoud fail with invalid binary 78 | statement error 79 | CALL from_substrait('ongezoutennoten') 80 | ---- 81 | No function matches the given name and argument types 'from_substrait(VARCHAR)' 82 | 83 | # Should fail on empty plan 84 | statement error 85 | CALL from_substrait(''::BLOB); 86 | ---- 87 | Substrait Plan does not have a SELECT statement 88 | -------------------------------------------------------------------------------- /test/sql/test_substrait_extract.test: -------------------------------------------------------------------------------- 1 | # name: test/sql/test_substrait_function_name.test 2 | # description: Test conversion of DuckDB built-in function names to Substrait function names 3 | # group: [sql] 4 | 5 | require substrait 6 | 7 | statement ok 8 | PRAGMA enable_verification 9 | 10 | statement ok 11 | CREATE table dates (d TIMESTAMP); 12 | 13 | statement ok 14 | INSERT INTO dates VALUES ('1992-09-20 20:38:48'), ('1971-09-15 15:14:28'), ('2030-01-03 03:01:54'); 15 | 16 | foreach component year month day decade century millenium quarter microsecond milliseconds second minute hour 17 | 18 | statement ok 19 | CALL get_substrait_json('SELECT extract(${component} FROM d) FROM dates'); 20 | 21 | #component 22 | endloop 23 | -------------------------------------------------------------------------------- /test/sql/test_substrait_function_name.test: -------------------------------------------------------------------------------- 1 | # name: test/sql/test_substrait_function_name.test 2 | # description: Test conversion of DuckDB built-in function names to Substrait function names 3 | # group: [sql] 4 | 5 | require substrait 6 | 7 | statement ok 8 | PRAGMA enable_verification 9 | 10 | statement ok 11 | CREATE table ints (i INT); 12 | 13 | statement ok 14 | INSERT INTO ints VALUES (-10), (100), (3), (43); 15 | 16 | statement ok 17 | CREATE table varchars (v VARCHAR); 18 | 19 | statement ok 20 | INSERT INTO varchars VALUES ('Duck'), ('DB'), ('🦆'), ('Quack'); 21 | 22 | statement ok 23 | CALL get_substrait('SELECT stddev(i) FROM ints'); 24 | 25 | statement ok 26 | CALL get_substrait('SELECT count(i) FROM ints'); 27 | 28 | statement ok 29 | CALL get_substrait('SELECT mod(i,3) FROM ints'); 30 | 31 | statement ok 32 | CALL get_substrait('SELECT sum(i) FROM ints'); 33 | 34 | statement ok 35 | CALL get_substrait('SELECT abs(i) FROM ints'); 36 | 37 | statement ok 38 | CALL get_substrait('SELECT prefix(v, ''1'') FROM varchars'); 39 | 40 | statement ok 41 | CALL get_substrait('SELECT suffix(v, ''3'') FROM varchars'); 42 | 43 | statement ok 44 | CALL get_substrait('SELECT substr(v, 1, 1) FROM varchars'); 45 | 46 | statement ok 47 | CALL get_substrait('SELECT length(v) FROM varchars'); 48 | 49 | statement ok 50 | CALL get_substrait('SELECT isnan(i) FROM ints'); 51 | 52 | statement ok 53 | CALL get_substrait('SELECT isinf(i) FROM ints'); 54 | 55 | statement ok 56 | CALL get_substrait('SELECT isfinite(i) FROM ints'); 57 | 58 | # ------------------------------------------------------------------------------------- 59 | 60 | statement ok 61 | CALL get_substrait_json('SELECT * FROM varchars WHERE v LIKE ''Q%a%'''); 62 | 63 | query I 64 | SELECT * FROM varchars WHERE v LIKE 'Q%a%k' 65 | ---- 66 | Quack 67 | -------------------------------------------------------------------------------- /test/sql/test_substrait_in.test: -------------------------------------------------------------------------------- 1 | # name: test/sql/test_substrait_in.test 2 | # description: Test get_substrait on in clauses 3 | # group: [sql] 4 | 5 | require substrait 6 | 7 | statement ok 8 | PRAGMA enable_verification 9 | 10 | statement ok 11 | CREATE TABLE test (a int); 12 | 13 | statement ok 14 | insert into test values (1), (2), (3), (100) 15 | 16 | statement ok 17 | CALL get_substrait('select * from test where a in (1, 7, 10,50,100);', enable_optimizer=false) 18 | -------------------------------------------------------------------------------- /test/sql/test_substrait_issue_01.test: -------------------------------------------------------------------------------- 1 | # name: test/sql/test_substrait_issue_01.test 2 | # description: Test get_substrait on issue#1 3 | # group: [sql] 4 | 5 | require substrait 6 | 7 | statement ok 8 | PRAGMA enable_verification 9 | 10 | statement ok 11 | create table t (a int) 12 | 13 | statement ok 14 | INSERT INTO t VALUES (1), (2), (3), (NULL); 15 | 16 | # is null (is_null) 17 | statement ok 18 | CALL get_substrait('select a from t WHERE a IS NULL') 19 | 20 | 21 | # not (not) 22 | statement ok 23 | CALL get_substrait('select a from t WHERE NOT a=1') 24 | 25 | # is not distinct from (is_not_distinct_from) 26 | statement ok 27 | CALL get_substrait('select a from t WHERE NOT a IS NOT DISTINCT FROM NULL') 28 | 29 | statement ok 30 | DROP TABLE t 31 | 32 | statement ok 33 | create table t (a DATE) 34 | 35 | statement ok 36 | INSERT INTO t VALUES ('1992-07-30'), (NULL); 37 | 38 | # interval (add) - Trying to add/substract an interval causes the error: SELECT L_SHIPDATE, L_SHIPDATE + INTERVAL 5 DAY 39 | statement ok 40 | CALL get_substrait('select a + INTERVAL 5 DAY from t') 41 | 42 | statement ok 43 | CALL get_substrait('select a - INTERVAL 5 DAY from t') 44 | 45 | -------------------------------------------------------------------------------- /test/sql/test_substrait_json.test: -------------------------------------------------------------------------------- 1 | # name: test/sql/test_substrait_json.test 2 | # description: Test get_substrait_json and from_substrait_json basic functionality 3 | # group: [sql] 4 | 5 | require substrait 6 | 7 | statement ok 8 | PRAGMA enable_verification 9 | 10 | statement ok 11 | CREATE TABLE integers (i integer) 12 | 13 | statement ok 14 | insert into integers values (1),(6) 15 | 16 | statement ok 17 | CALL get_substrait_json('select * from integers limit 5') 18 | -------------------------------------------------------------------------------- /test/sql/test_substrait_parquet.test: -------------------------------------------------------------------------------- 1 | # name: test/sql/test_substrait_parquet.test 2 | # description: Test get_substrait and from_substrait from parquet 3 | # group: [sql] 4 | 5 | require substrait 6 | 7 | statement ok 8 | PRAGMA enable_verification 9 | 10 | require parquet 11 | 12 | statement ok 13 | CALL get_substrait('SELECT sum(l_extendedprice * l_discount) as revenue FROM parquet_scan(''data/parquet-testing/lineitem-top10000.gzip.parquet'')') 14 | 15 | # Test from a parquet view 16 | 17 | statement ok 18 | CREATE TABLE lineitem_parquet AS SELECT * FROM parquet_scan('data/parquet-testing/lineitem-top10000.gzip.parquet') 19 | 20 | statement ok 21 | DROP TABLE lineitem_parquet; 22 | 23 | statement ok 24 | CREATE VIEW lineitem_parquet AS SELECT * FROM parquet_scan('data/parquet-testing/lineitem-top10000.gzip.parquet') 25 | 26 | # Verify that we can re-use the query plan on a view instead 27 | query I 28 | CALL from_substrait('\x12\x07\x1A\x05\x10\x01\x1A\x01*\x12\x09\x1A\x07\x10\x02\x1A\x03sum\x1A\xB7\x03\x12\xB4\x03\x0A\xA8\x03\x22\xA5\x03\x12\xEC\x02\x0A\xE9\x02\x12\xC4\x02\x0A\x0Al_orderkey\x0A\x09l_partkey\x0A\x09l_suppkey\x0A\x0Cl_linenumber\x0A\x0Al_quantity\x0A\x0Fl_extendedprice\x0A\x0Al_discount\x0A\x05l_tax\x0A\x0Cl_returnflag\x0A\x0Cl_linestatus\x0A\x0Al_shipdate\x0A\x0Cl_commitdate\x0A\x0Dl_receiptdate\x0A\x0El_shipinstruct\x0A\x0Al_shipmode\x0A\x09l_comment\x12v\x0A\x04:\x02\x10\x01\x0A\x04:\x02\x10\x01\x0A\x04:\x02\x10\x01\x0A\x02*\x00\x0A\x02*\x00\x0A\x04Z\x02\x10\x01\x0A\x04Z\x02\x10\x01\x0A\x04Z\x02\x10\x01\x0A\x07\xB2\x01\x04\x08\x01\x18\x01\x0A\x07\xB2\x01\x04\x08\x01\x18\x01\x0A\x07\xB2\x01\x04\x08\x0A\x18\x01\x0A\x07\xB2\x01\x04\x08\x0A\x18\x01\x0A\x07\xB2\x01\x04\x08\x0A\x18\x01\x0A\x07\xB2\x01\x04\x08\x11\x18\x01\x0A\x07\xB2\x01\x04\x08\x07\x18\x01\x0A\x07\xB2\x01\x04\x08+\x18\x01\x18\x02\x22\x0C\x0A\x08\x0A\x02\x08\x05\x0A\x02\x08\x06\x10\x01:\x12\x0A\x10lineitem_parquet\x1A\x00\x222\x0A0\x08\x02*\x04Z\x02\x10\x01:&\x1A$\x1A\x22\x08\x01\x1A\x04Z\x02\x10\x01\x22\x0A\x1A\x08\x12\x06\x0A\x02\x12\x00\x22\x00\x22\x0C\x1A\x0A\x12\x08\x0A\x04\x12\x02\x08\x01\x22\x00\x12\x07revenue2\x0A\x100*\x06DuckDB'::BLOB) 29 | ---- 30 | 19107076.83379995 31 | 32 | # Test Globbing 33 | statement ok 34 | CALL get_substrait('select * from parquet_scan(''data/parquet-testing/glob*/t?.parquet'') order by i') 35 | 36 | statement error 37 | CALL get_substrait('select * from parquet_scan('''') order by i') 38 | ---- 39 | No files found that match the pattern "" 40 | 41 | -------------------------------------------------------------------------------- /test/sql/test_substrait_scalar.test: -------------------------------------------------------------------------------- 1 | # name: test/sql/test_substrait_scalar.test 2 | # description: Test scalar functions with substrait 3 | # group: [sql] 4 | 5 | require substrait 6 | 7 | statement ok 8 | PRAGMA enable_verification 9 | 10 | statement ok 11 | create table t (a date) 12 | 13 | statement ok 14 | insert into t values ('1992-07-30') 15 | 16 | statement ok 17 | CALL get_substrait('SELECT EXTRACT(year FROM a) FROM t') 18 | -------------------------------------------------------------------------------- /test/sql/test_substrait_schema_json.test: -------------------------------------------------------------------------------- 1 | # name: test/sql/test_substrait_schema_json.test 2 | # description: Test scalar functions with substrait 3 | # group: [sql] 4 | 5 | require substrait 6 | 7 | statement ok 8 | PRAGMA enable_verification 9 | 10 | # Test Nullability 11 | statement ok 12 | CREATE TABLE type (a integer not null) 13 | 14 | statement ok 15 | CALL get_substrait_json('select * from type;') 16 | 17 | statement ok 18 | drop table type 19 | 20 | statement ok 21 | CREATE TABLE type (a integer) 22 | 23 | statement ok 24 | CALL get_substrait_json('select * from type;') 25 | 26 | statement ok 27 | drop table type 28 | 29 | statement ok 30 | CREATE TABLE type (a integer, b varchar, c decimal (3,2)) 31 | 32 | # Multiple columns 33 | 34 | statement ok 35 | CALL get_substrait_json('select * from type;') 36 | 37 | statement ok 38 | insert into type values (0, 'abc',0) 39 | 40 | # Varchar with length due to statistics 41 | 42 | statement ok 43 | CALL get_substrait_json('select * from type;') 44 | 45 | statement ok 46 | CREATE TABLE integers (i integer) 47 | 48 | statement ok 49 | CALL get_substrait_json('select * from integers limit 5') 50 | -------------------------------------------------------------------------------- /test/sql/test_substrait_simple.test: -------------------------------------------------------------------------------- 1 | # name: test/sql/test_substrait_simple.test 2 | # description: Test get_substrait with simple operators 3 | # group: [sql] 4 | 5 | require substrait 6 | 7 | statement ok 8 | PRAGMA enable_verification 9 | 10 | statement ok 11 | CREATE TABLE person (name text,money int); 12 | 13 | statement ok 14 | insert into person values ('Pedro', 10); 15 | 16 | statement ok 17 | CALL get_substrait('select * from person') 18 | 19 | # Test simple projection 20 | statement ok 21 | CALL get_substrait('select name from person') 22 | 23 | statement ok 24 | insert into person values ('Richard', 20); 25 | 26 | # Test Simple Filter 27 | statement ok 28 | CALL get_substrait('select * from person where name = ''Pedro''') 29 | 30 | # Test Simple Aggregation 31 | statement ok 32 | insert into person values ('Pedro', 20); 33 | 34 | statement ok 35 | CALL get_substrait('select SUM(money) from person') 36 | 37 | # Test aggregation + Filter 38 | statement ok 39 | CALL get_substrait('select SUM(money) from person where name = ''Pedro''') 40 | 41 | statement ok 42 | drop table person 43 | 44 | statement ok 45 | CREATE TABLE person (money DECIMAL(5,2)) 46 | 47 | statement ok 48 | insert into person values (105.35), (1.11) 49 | 50 | # Test aggregation on decimals 51 | statement ok 52 | CALL get_substrait('select SUM(money * 2) as double_money from person') 53 | 54 | statement ok 55 | drop table person 56 | 57 | statement ok 58 | CREATE TABLE person (name text) 59 | 60 | statement ok 61 | insert into person values ('bla special bla requests bla'),('special requests'),('bla') 62 | 63 | # Test filters on strings 64 | statement ok 65 | CALL get_substrait('select * from person where name not like ''%special%requests%''') 66 | -------------------------------------------------------------------------------- /test/sql/test_substrait_subqueries.test: -------------------------------------------------------------------------------- 1 | # name: test/sql/test_substrait_subqueries.test 2 | # description: Test get_substrait with simple subqueries 3 | # group: [sql] 4 | 5 | require substrait 6 | 7 | statement ok 8 | PRAGMA enable_verification 9 | 10 | statement ok 11 | CREATE TABLE integers (i integer); 12 | 13 | statement ok 14 | insert into integers values (1),(2),(3),(NULL); 15 | 16 | # Uncorrelated Scalar 17 | statement ok 18 | CALL get_substrait('select i, i + (select MIN(i) from integers) from integers order by i') 19 | 20 | # Uncorrelated Any (Missing Mark Join) 21 | #statement ok 22 | #CALL get_substrait('select i = ANY(select * from integers where i is not null) from integers') 23 | 24 | # Uncorrelated Exist 25 | statement ok 26 | CALL get_substrait('select i, exists (select * from integers where i > 2) from integers') 27 | 28 | # Self-Join 29 | statement ok 30 | CALL get_substrait('select i1.i from integers i1 inner join integers i2 on (i1.i = i2.i)') 31 | 32 | #Double subquery 33 | statement ok 34 | CALL get_substrait('select i from integers where i >= (select min (i) from integers) and i <= (select max (i) from integers) ') 35 | 36 | # Skipping this test for now beucase it is part of the big posref refactoring 37 | #statement ok 38 | #CALL get_substrait('select i from integers where i in (select i from integers where i <= 4) and i = (select min (i) from integers) ') 39 | -------------------------------------------------------------------------------- /test/sql/test_substrait_topn.test: -------------------------------------------------------------------------------- 1 | # name: test/sql/test_substrait_topn.test 2 | # description: Test get_substrait with top-n queries 3 | # group: [sql] 4 | 5 | require substrait 6 | 7 | statement ok 8 | PRAGMA enable_verification 9 | 10 | statement ok 11 | CREATE TABLE test (i integer,j VARCHAR, k varchar ); 12 | 13 | statement ok 14 | insert into test values (10,'a','a'), (20,'a','b'); 15 | 16 | statement ok 17 | CALL get_substrait('select k,i from test order by k limit 1') 18 | 19 | statement ok 20 | CALL get_substrait('select k,i from test order by i limit 1') 21 | 22 | statement ok 23 | CALL get_substrait('select k from test order by i limit 1') 24 | 25 | statement ok 26 | CALL get_substrait('select k,i from test order by j limit 1') 27 | 28 | statement ok 29 | CALL get_substrait('select j,i from test where k < ''f'' limit 1') 30 | -------------------------------------------------------------------------------- /test/sql/test_temporary_view.test: -------------------------------------------------------------------------------- 1 | # name: test/sql/test_temporary_view.test 2 | # description: Test we can run queries on a temporary view 3 | # group: [sql] 4 | 5 | require substrait 6 | 7 | 8 | statement ok 9 | CREATE TABLE tbl (age INTEGER, name STRING) 10 | 11 | statement ok 12 | INSERT INTO tbl VALUES (1, 'Alice'), (2, 'Bob') 13 | 14 | statement ok 15 | CREATE TEMPORARY VIEW mytempview AS SELECT * FROM tbl; 16 | 17 | query II 18 | select * from mytempview 19 | ---- 20 | 1 Alice 21 | 2 Bob 22 | 23 | 24 | statement ok 25 | call get_substrait('SELECT * FROM mytempview') 26 | 27 | query II 28 | call from_substrait('\x1AA\x12?\x0A2\x0A0\x12\x1B\x0A\x03age\x0A\x04name\x12\x0E\x0A\x04*\x02\x10\x01\x0A\x04b\x02\x10\x01\x18\x02\x22\x0A\x0A\x06\x0A\x00\x0A\x02\x08\x01\x10\x01:\x05\x0A\x03tbl\x12\x03age\x12\x04name2\x0A\x105*\x06DuckDB'::BLOB) 29 | ---- 30 | 1 Alice 31 | 2 Bob -------------------------------------------------------------------------------- /test/sql/test_union.test: -------------------------------------------------------------------------------- 1 | # name: test/sql/test_union.test 2 | # description: Test the UNION set operation 3 | # group: [sql] 4 | 5 | require substrait 6 | 7 | statement ok 8 | PRAGMA enable_verification 9 | 10 | # Create two tables to use in UNION 11 | 12 | statement ok 13 | create table tbl1 as select * from (VALUES 14 | (1, 2, 3, 4), 15 | (2, 3, 4, 5), 16 | (3, 4, 5, 6)) as tbl(A, B, C, D); 17 | 18 | statement ok 19 | create table tbl2 as select * from (VALUES 20 | (11, 12, 13, 14, 15), 21 | (12, 13, 14, 15, 16), 22 | (13, 14, 15, 16, 17)) as tbl (A, B, C, D, E); 23 | 24 | statement ok 25 | CALL get_substrait(' 26 | select * from( 27 | select A, B, C, D, 0 as E from tbl1 28 | ) 29 | union all ( 30 | select * from tbl2 31 | )') 32 | -------------------------------------------------------------------------------- /test/sql/test_virtual_table.test: -------------------------------------------------------------------------------- 1 | # name: test/sql/test_virtual_table.test 2 | # description: Test literal conversion with substrait virtual tables 3 | # group: [sql] 4 | 5 | require substrait 6 | 7 | statement ok 8 | PRAGMA enable_verification 9 | 10 | statement ok 11 | CALL get_substrait('select 42') 12 | 13 | # Force projection order 14 | statement ok 15 | CALL get_substrait('select age, name from (select ''Oogie Boogie'' as name, 3 as age) as t') 16 | 17 | # Force multiple rows 18 | statement ok 19 | create table t as select * from range(10); 20 | 21 | statement ok 22 | CALL get_substrait('select age, name from (select ''Oogie Boogie'' as name, 3 as age from t) as t_2') -------------------------------------------------------------------------------- /third_party/google/protobuf/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2008 Google Inc. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are 5 | met: 6 | 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above 10 | copyright notice, this list of conditions and the following disclaimer 11 | in the documentation and/or other materials provided with the 12 | distribution. 13 | * Neither the name of Google Inc. nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | 29 | Code generated by the Protocol Buffer compiler is owned by the owner 30 | of the input file used when generating it. This code is not 31 | standalone and requires a support library to be linked with it. This 32 | support library is itself covered by the above license. 33 | -------------------------------------------------------------------------------- /third_party/google/protobuf/any.cc: -------------------------------------------------------------------------------- 1 | // Protocol Buffers - Google's data interchange format 2 | // Copyright 2008 Google Inc. All rights reserved. 3 | // https://developers.google.com/protocol-buffers/ 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are 7 | // met: 8 | // 9 | // * Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // * Redistributions in binary form must reproduce the above 12 | // copyright notice, this list of conditions and the following disclaimer 13 | // in the documentation and/or other materials provided with the 14 | // distribution. 15 | // * Neither the name of Google Inc. nor the names of its 16 | // contributors may be used to endorse or promote products derived from 17 | // this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | #include 32 | 33 | #include 34 | #include 35 | #include 36 | #include 37 | 38 | #include 39 | namespace duckdb { 40 | namespace google { 41 | namespace protobuf { 42 | namespace internal { 43 | 44 | bool AnyMetadata::PackFrom(Arena* arena, const Message& message) { 45 | return PackFrom(arena, message, kTypeGoogleApisComPrefix); 46 | } 47 | 48 | bool AnyMetadata::PackFrom(Arena* arena, const Message& message, 49 | StringPiece type_url_prefix) { 50 | type_url_->Set( 51 | &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString(), 52 | GetTypeUrl(message.GetDescriptor()->full_name(), type_url_prefix), arena); 53 | return message.SerializeToString( 54 | value_->Mutable(ArenaStringPtr::EmptyDefault{}, arena)); 55 | } 56 | 57 | bool AnyMetadata::UnpackTo(Message* message) const { 58 | if (!InternalIs(message->GetDescriptor()->full_name())) { 59 | return false; 60 | } 61 | return message->ParseFromString(value_->Get()); 62 | } 63 | 64 | bool GetAnyFieldDescriptors(const Message& message, 65 | const FieldDescriptor** type_url_field, 66 | const FieldDescriptor** value_field) { 67 | const Descriptor* descriptor = message.GetDescriptor(); 68 | if (descriptor->full_name() != kAnyFullTypeName) { 69 | return false; 70 | } 71 | *type_url_field = descriptor->FindFieldByNumber(1); 72 | *value_field = descriptor->FindFieldByNumber(2); 73 | return (*type_url_field != nullptr && 74 | (*type_url_field)->type() == FieldDescriptor::TYPE_STRING && 75 | *value_field != nullptr && 76 | (*value_field)->type() == FieldDescriptor::TYPE_BYTES); 77 | } 78 | 79 | } // namespace internal 80 | } // namespace protobuf 81 | } // namespace google 82 | } // namespace duckdb 83 | #include 84 | -------------------------------------------------------------------------------- /third_party/google/protobuf/any_lite.cc: -------------------------------------------------------------------------------- 1 | // Protocol Buffers - Google's data interchange format 2 | // Copyright 2008 Google Inc. All rights reserved. 3 | // https://developers.google.com/protocol-buffers/ 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are 7 | // met: 8 | // 9 | // * Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // * Redistributions in binary form must reproduce the above 12 | // copyright notice, this list of conditions and the following disclaimer 13 | // in the documentation and/or other materials provided with the 14 | // distribution. 15 | // * Neither the name of Google Inc. nor the names of its 16 | // contributors may be used to endorse or promote products derived from 17 | // this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | #include 32 | 33 | #include 34 | #include 35 | #include 36 | #include 37 | 38 | namespace duckdb { 39 | namespace google { 40 | namespace protobuf { 41 | namespace internal { 42 | 43 | std::string GetTypeUrl(StringPiece message_name, StringPiece type_url_prefix) { 44 | if (!type_url_prefix.empty() && type_url_prefix[type_url_prefix.size() - 1] == '/') { 45 | return StrCat(type_url_prefix, message_name); 46 | } else { 47 | return StrCat(type_url_prefix, "/", message_name); 48 | } 49 | } 50 | 51 | const char kAnyFullTypeName[] = "google.protobuf.Any"; 52 | const char kTypeGoogleApisComPrefix[] = "type.googleapis.com/"; 53 | const char kTypeGoogleProdComPrefix[] = "type.googleprod.com/"; 54 | 55 | bool AnyMetadata::InternalPackFrom(Arena *arena, const MessageLite &message, StringPiece type_url_prefix, 56 | StringPiece type_name) { 57 | type_url_->Set(&duckdb::google::protobuf::internal::GetEmptyString(), GetTypeUrl(type_name, type_url_prefix), 58 | arena); 59 | return message.SerializeToString(value_->Mutable(ArenaStringPtr::EmptyDefault {}, arena)); 60 | } 61 | 62 | bool AnyMetadata::InternalUnpackTo(StringPiece type_name, MessageLite *message) const { 63 | if (!InternalIs(type_name)) { 64 | return false; 65 | } 66 | return message->ParseFromString(value_->Get()); 67 | } 68 | 69 | bool AnyMetadata::InternalIs(StringPiece type_name) const { 70 | StringPiece type_url = type_url_->Get(); 71 | return type_url.size() >= type_name.size() + 1 && type_url[type_url.size() - type_name.size() - 1] == '/' && 72 | HasSuffixString(type_url, type_name); 73 | } 74 | 75 | bool ParseAnyTypeUrl(StringPiece type_url, std::string *url_prefix, std::string *full_type_name) { 76 | size_t pos = type_url.find_last_of('/'); 77 | if (pos == std::string::npos || pos + 1 == type_url.size()) { 78 | return false; 79 | } 80 | if (url_prefix) { 81 | *url_prefix = std::string(type_url.substr(0, pos + 1)); 82 | } 83 | *full_type_name = std::string(type_url.substr(pos + 1)); 84 | return true; 85 | } 86 | 87 | bool ParseAnyTypeUrl(StringPiece type_url, std::string *full_type_name) { 88 | return ParseAnyTypeUrl(type_url, nullptr, full_type_name); 89 | } 90 | 91 | } // namespace internal 92 | } // namespace protobuf 93 | } // namespace google 94 | } // namespace duckdb -------------------------------------------------------------------------------- /third_party/google/protobuf/explicitly_constructed.h: -------------------------------------------------------------------------------- 1 | // Protocol Buffers - Google's data interchange format 2 | // Copyright 2008 Google Inc. All rights reserved. 3 | // https://developers.google.com/protocol-buffers/ 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are 7 | // met: 8 | // 9 | // * Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // * Redistributions in binary form must reproduce the above 12 | // copyright notice, this list of conditions and the following disclaimer 13 | // in the documentation and/or other materials provided with the 14 | // distribution. 15 | // * Neither the name of Google Inc. nor the names of its 16 | // contributors may be used to endorse or promote products derived from 17 | // this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | #ifndef GOOGLE_PROTOBUF_EXPLICITLY_CONSTRUCTED_H__ 32 | #define GOOGLE_PROTOBUF_EXPLICITLY_CONSTRUCTED_H__ 33 | 34 | #include 35 | 36 | #include 37 | 38 | #include 39 | #include 40 | 41 | // clang-format off 42 | #include 43 | // clang-format on 44 | 45 | namespace duckdb{ 46 | namespace google { 47 | namespace protobuf { 48 | namespace internal { 49 | 50 | // Wraps a variable whose constructor and destructor are explicitly 51 | // called. It is particularly useful for a global variable, without its 52 | // constructor and destructor run on start and end of the program lifetime. 53 | // This circumvents the initial construction order fiasco, while keeping 54 | // the address of the empty string a compile time constant. 55 | // 56 | // Pay special attention to the initialization state of the object. 57 | // 1. The object is "uninitialized" to begin with. 58 | // 2. Call Construct() or DefaultConstruct() only if the object is 59 | // uninitialized. After the call, the object becomes "initialized". 60 | // 3. Call get() and get_mutable() only if the object is initialized. 61 | // 4. Call Destruct() only if the object is initialized. 62 | // After the call, the object becomes uninitialized. 63 | template 64 | class ExplicitlyConstructed { 65 | public: 66 | void DefaultConstruct() { new (&union_) T(); } 67 | 68 | template 69 | void Construct(Args&&... args) { 70 | new (&union_) T(std::forward(args)...); 71 | } 72 | 73 | void Destruct() { get_mutable()->~T(); } 74 | 75 | constexpr const T& get() const { return reinterpret_cast(union_); } 76 | T* get_mutable() { return reinterpret_cast(&union_); } 77 | 78 | private: 79 | union AlignedUnion { 80 | alignas(T) char space[sizeof(T)]; 81 | int64_t align_to_int64; 82 | void* align_to_ptr; 83 | } union_; 84 | }; 85 | 86 | } // namespace internal 87 | } // namespace protobuf 88 | } // namespace google 89 | } // namespace duckdb 90 | #include 91 | 92 | #endif // GOOGLE_PROTOBUF_EXPLICITLY_CONSTRUCTED_H__ 93 | -------------------------------------------------------------------------------- /third_party/google/protobuf/generated_enum_reflection.h: -------------------------------------------------------------------------------- 1 | // Protocol Buffers - Google's data interchange format 2 | // Copyright 2008 Google Inc. All rights reserved. 3 | // https://developers.google.com/protocol-buffers/ 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are 7 | // met: 8 | // 9 | // * Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // * Redistributions in binary form must reproduce the above 12 | // copyright notice, this list of conditions and the following disclaimer 13 | // in the documentation and/or other materials provided with the 14 | // distribution. 15 | // * Neither the name of Google Inc. nor the names of its 16 | // contributors may be used to endorse or promote products derived from 17 | // this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | // Author: jasonh@google.com (Jason Hsueh) 32 | // 33 | // This header is logically internal, but is made public because it is used 34 | // from protocol-compiler-generated code, which may reside in other components. 35 | // It provides reflection support for generated enums, and is included in 36 | // generated .pb.h files and should have minimal dependencies. The methods are 37 | // implemented in generated_message_reflection.cc. 38 | 39 | #ifndef GOOGLE_PROTOBUF_GENERATED_ENUM_REFLECTION_H__ 40 | #define GOOGLE_PROTOBUF_GENERATED_ENUM_REFLECTION_H__ 41 | 42 | #include 43 | 44 | #include 45 | #include 46 | #include 47 | 48 | #ifdef SWIG 49 | #error "You cannot SWIG proto headers" 50 | #endif 51 | 52 | #include 53 | namespace duckdb { 54 | namespace google { 55 | namespace protobuf { 56 | class EnumDescriptor; 57 | } // namespace protobuf 58 | } // namespace google 59 | } // namespace duckdb 60 | namespace duckdb { 61 | namespace google { 62 | namespace protobuf { 63 | 64 | // Returns the EnumDescriptor for enum type E, which must be a 65 | // proto-declared enum type. Code generated by the protocol compiler 66 | // will include specializations of this template for each enum type declared. 67 | template 68 | const EnumDescriptor *GetEnumDescriptor(); 69 | 70 | namespace internal { 71 | 72 | // Helper for EnumType_Parse functions: try to parse the string 'name' as 73 | // an enum name of the given type, returning true and filling in value on 74 | // success, or returning false and leaving value unchanged on failure. 75 | bool ParseNamedEnum(const EnumDescriptor *descriptor, ConstStringParam name, int *value); 76 | 77 | template 78 | bool ParseNamedEnum(const EnumDescriptor *descriptor, ConstStringParam name, EnumType *value) { 79 | int tmp; 80 | if (!ParseNamedEnum(descriptor, name, &tmp)) 81 | return false; 82 | *value = static_cast(tmp); 83 | return true; 84 | } 85 | 86 | // Just a wrapper around printing the name of a value. The main point of this 87 | // function is not to be inlined, so that you can do this without including 88 | // descriptor.h. 89 | const std::string &NameOfEnum(const EnumDescriptor *descriptor, int value); 90 | 91 | } // namespace internal 92 | } // namespace protobuf 93 | } // namespace google 94 | } // namespace duckdb 95 | #include 96 | 97 | #endif // GOOGLE_PROTOBUF_GENERATED_ENUM_REFLECTION_H__ 98 | -------------------------------------------------------------------------------- /third_party/google/protobuf/generated_enum_util.cc: -------------------------------------------------------------------------------- 1 | // Protocol Buffers - Google's data interchange format 2 | // Copyright 2008 Google Inc. All rights reserved. 3 | // https://developers.google.com/protocol-buffers/ 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are 7 | // met: 8 | // 9 | // * Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // * Redistributions in binary form must reproduce the above 12 | // copyright notice, this list of conditions and the following disclaimer 13 | // in the documentation and/or other materials provided with the 14 | // distribution. 15 | // * Neither the name of Google Inc. nor the names of its 16 | // contributors may be used to endorse or promote products derived from 17 | // this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | #include 32 | 33 | #include 34 | 35 | #include 36 | 37 | namespace duckdb { 38 | namespace google { 39 | namespace protobuf { 40 | namespace internal { 41 | namespace { 42 | 43 | bool EnumCompareByName(const EnumEntry &a, const EnumEntry &b) { 44 | return StringPiece(a.name) < StringPiece(b.name); 45 | } 46 | 47 | // Gets the numeric value of the EnumEntry at the given index, but returns a 48 | // special value for the index -1. This gives a way to use std::lower_bound on a 49 | // sorted array of indices while searching for value that we associate with -1. 50 | int GetValue(const EnumEntry *enums, int i, int target) { 51 | if (i == -1) { 52 | return target; 53 | } else { 54 | return enums[i].value; 55 | } 56 | } 57 | 58 | } // namespace 59 | 60 | bool LookUpEnumValue(const EnumEntry *enums, size_t size, StringPiece name, int *value) { 61 | EnumEntry target {name, 0}; 62 | auto it = std::lower_bound(enums, enums + size, target, EnumCompareByName); 63 | if (it != enums + size && it->name == name) { 64 | *value = it->value; 65 | return true; 66 | } 67 | return false; 68 | } 69 | 70 | int LookUpEnumName(const EnumEntry *enums, const int *sorted_indices, size_t size, int value) { 71 | auto comparator = [enums, value](int a, int b) { 72 | return GetValue(enums, a, value) < GetValue(enums, b, value); 73 | }; 74 | auto it = std::lower_bound(sorted_indices, sorted_indices + size, -1, comparator); 75 | if (it != sorted_indices + size && enums[*it].value == value) { 76 | return it - sorted_indices; 77 | } 78 | return -1; 79 | } 80 | 81 | bool InitializeEnumStrings(const EnumEntry *enums, const int *sorted_indices, size_t size, 82 | internal::ExplicitlyConstructed *enum_strings) { 83 | for (size_t i = 0; i < size; ++i) { 84 | enum_strings[i].Construct(enums[sorted_indices[i]].name); 85 | internal::OnShutdownDestroyString(enum_strings[i].get_mutable()); 86 | } 87 | return true; 88 | } 89 | 90 | } // namespace internal 91 | } // namespace protobuf 92 | } // namespace google 93 | } // namespace duckdb -------------------------------------------------------------------------------- /third_party/google/protobuf/generated_enum_util.h: -------------------------------------------------------------------------------- 1 | // Protocol Buffers - Google's data interchange format 2 | // Copyright 2008 Google Inc. All rights reserved. 3 | // https://developers.google.com/protocol-buffers/ 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are 7 | // met: 8 | // 9 | // * Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // * Redistributions in binary form must reproduce the above 12 | // copyright notice, this list of conditions and the following disclaimer 13 | // in the documentation and/or other materials provided with the 14 | // distribution. 15 | // * Neither the name of Google Inc. nor the names of its 16 | // contributors may be used to endorse or promote products derived from 17 | // this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | #ifndef GOOGLE_PROTOBUF_GENERATED_ENUM_UTIL_H__ 32 | #define GOOGLE_PROTOBUF_GENERATED_ENUM_UTIL_H__ 33 | 34 | #include 35 | 36 | #include 37 | #include 38 | 39 | #include 40 | 41 | #ifdef SWIG 42 | #error "You cannot SWIG proto headers" 43 | #endif 44 | namespace duckdb { 45 | namespace google { 46 | namespace protobuf { 47 | 48 | // This type trait can be used to cause templates to only match proto2 enum 49 | // types. 50 | template 51 | struct is_proto_enum : ::std::false_type {}; 52 | 53 | namespace internal { 54 | 55 | // The table entry format for storing enum name-to-value mapping used with lite 56 | // protos. This struct and the following related functions should only be used 57 | // by protobuf generated code. 58 | struct EnumEntry { 59 | StringPiece name; 60 | int value; 61 | }; 62 | 63 | // Looks up a numeric enum value given the string name. 64 | bool LookUpEnumValue(const EnumEntry *enums, size_t size, StringPiece name, int *value); 65 | 66 | // Looks up an enum name given the numeric value. 67 | int LookUpEnumName(const EnumEntry *enums, const int *sorted_indices, size_t size, int value); 68 | 69 | // Initializes the list of enum names in std::string form. 70 | bool InitializeEnumStrings(const EnumEntry *enums, const int *sorted_indices, size_t size, 71 | internal::ExplicitlyConstructed *enum_strings); 72 | 73 | } // namespace internal 74 | } // namespace protobuf 75 | } // namespace google 76 | } // namespace duckdb 77 | #include 78 | 79 | #endif // GOOGLE_PROTOBUF_GENERATED_ENUM_UTIL_H__ 80 | -------------------------------------------------------------------------------- /third_party/google/protobuf/generated_message_bases.cc: -------------------------------------------------------------------------------- 1 | // Protocol Buffers - Google's data interchange format 2 | // Copyright 2008 Google Inc. All rights reserved. 3 | // https://developers.google.com/protocol-buffers/ 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are 7 | // met: 8 | // 9 | // * Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // * Redistributions in binary form must reproduce the above 12 | // copyright notice, this list of conditions and the following disclaimer 13 | // in the documentation and/or other materials provided with the 14 | // distribution. 15 | // * Neither the name of Google Inc. nor the names of its 16 | // contributors may be used to endorse or promote products derived from 17 | // this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | #include 32 | 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | 40 | // Must be last: 41 | #include 42 | 43 | namespace duckdb { 44 | namespace google { 45 | namespace protobuf { 46 | namespace internal { 47 | 48 | // ============================================================================= 49 | // ZeroFieldsBase 50 | 51 | void ZeroFieldsBase::Clear() { 52 | _internal_metadata_.Clear(); // 53 | } 54 | 55 | ZeroFieldsBase::~ZeroFieldsBase() { 56 | if (GetArenaForAllocation() != nullptr) 57 | return; 58 | _internal_metadata_.Delete(); 59 | } 60 | 61 | size_t ZeroFieldsBase::ByteSizeLong() const { 62 | return MaybeComputeUnknownFieldsSize(0, &_cached_size_); 63 | } 64 | 65 | const char *ZeroFieldsBase::_InternalParse(const char *ptr, internal::ParseContext *ctx) { 66 | #define CHK_(x) \ 67 | if (PROTOBUF_PREDICT_FALSE(!(x))) { \ 68 | goto failure; \ 69 | } 70 | 71 | while (!ctx->Done(&ptr)) { 72 | uint32_t tag; 73 | ptr = internal::ReadTag(ptr, &tag); 74 | if ((tag == 0) || ((tag & 7) == 4)) { 75 | CHK_(ptr); 76 | ctx->SetLastTag(tag); 77 | goto message_done; 78 | } 79 | ptr = UnknownFieldParse(tag, _internal_metadata_.mutable_unknown_fields(), ptr, ctx); 80 | CHK_(ptr); 81 | } // while 82 | message_done: 83 | return ptr; 84 | failure: 85 | ptr = nullptr; 86 | goto message_done; 87 | #undef CHK_ 88 | } 89 | 90 | ::uint8_t *ZeroFieldsBase::_InternalSerialize(::uint8_t *target, io::EpsCopyOutputStream *stream) const { 91 | if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { 92 | target = internal::WireFormat::InternalSerializeUnknownFieldsToArray( 93 | _internal_metadata_.unknown_fields(UnknownFieldSet::default_instance), target, stream); 94 | } 95 | return target; 96 | } 97 | 98 | void ZeroFieldsBase::MergeImpl(Message *to_param, const Message &from_param) { 99 | auto *to = static_cast(to_param); 100 | const auto *from = static_cast(&from_param); 101 | GOOGLE_DCHECK_NE(from, to); 102 | to->_internal_metadata_.MergeFrom(from->_internal_metadata_); 103 | } 104 | 105 | void ZeroFieldsBase::CopyImpl(Message *to_param, const Message &from_param) { 106 | auto *to = static_cast(to_param); 107 | const auto *from = static_cast(&from_param); 108 | if (from == to) 109 | return; 110 | to->_internal_metadata_.Clear(); 111 | to->_internal_metadata_.MergeFrom(from->_internal_metadata_); 112 | } 113 | 114 | void ZeroFieldsBase::InternalSwap(ZeroFieldsBase *other) { 115 | _internal_metadata_.Swap(&other->_internal_metadata_); 116 | } 117 | 118 | } // namespace internal 119 | } // namespace protobuf 120 | } // namespace google 121 | } // namespace duckdb 122 | #include 123 | -------------------------------------------------------------------------------- /third_party/google/protobuf/generated_message_bases.h: -------------------------------------------------------------------------------- 1 | // Protocol Buffers - Google's data interchange format 2 | // Copyright 2008 Google Inc. All rights reserved. 3 | // https://developers.google.com/protocol-buffers/ 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are 7 | // met: 8 | // 9 | // * Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // * Redistributions in binary form must reproduce the above 12 | // copyright notice, this list of conditions and the following disclaimer 13 | // in the documentation and/or other materials provided with the 14 | // distribution. 15 | // * Neither the name of Google Inc. nor the names of its 16 | // contributors may be used to endorse or promote products derived from 17 | // this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | // This file contains helpers for generated code. 32 | // 33 | // Nothing in this file should be directly referenced by users of protobufs. 34 | 35 | #ifndef GOOGLE_PROTOBUF_GENERATED_MESSAGE_BASES_H__ 36 | #define GOOGLE_PROTOBUF_GENERATED_MESSAGE_BASES_H__ 37 | 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include 43 | 44 | // Must come last: 45 | #include 46 | namespace duckdb { 47 | namespace google { 48 | namespace protobuf { 49 | namespace internal { 50 | 51 | // To save code size, protos without any fields are derived from ZeroFieldsBase 52 | // rather than Message. 53 | class ZeroFieldsBase : public Message { 54 | public: 55 | PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; 56 | bool IsInitialized() const final { 57 | return true; 58 | } 59 | size_t ByteSizeLong() const final; 60 | int GetCachedSize() const final { 61 | return _cached_size_.Get(); 62 | } 63 | const char *_InternalParse(const char *ptr, internal::ParseContext *ctx) final; 64 | ::uint8_t *_InternalSerialize(::uint8_t *target, io::EpsCopyOutputStream *stream) const final; 65 | 66 | protected: 67 | constexpr ZeroFieldsBase() { 68 | } 69 | explicit ZeroFieldsBase(Arena *arena, bool is_message_owned) : Message(arena, is_message_owned) { 70 | } 71 | ZeroFieldsBase(const ZeroFieldsBase &) = delete; 72 | ZeroFieldsBase &operator=(const ZeroFieldsBase &) = delete; 73 | ~ZeroFieldsBase() override; 74 | 75 | void SetCachedSize(int size) const final { 76 | _cached_size_.Set(size); 77 | } 78 | 79 | static void MergeImpl(Message *to, const Message &from); 80 | static void CopyImpl(Message *to, const Message &from); 81 | void InternalSwap(ZeroFieldsBase *other); 82 | 83 | mutable internal::CachedSize _cached_size_; 84 | }; 85 | 86 | } // namespace internal 87 | } // namespace protobuf 88 | } // namespace google 89 | } // namespace duckdb 90 | #include 91 | 92 | #endif // GOOGLE_PROTOBUF_GENERATED_MESSAGE_BASES_H__ 93 | -------------------------------------------------------------------------------- /third_party/google/protobuf/generated_message_table_driven.cc: -------------------------------------------------------------------------------- 1 | // Protocol Buffers - Google's data interchange format 2 | // Copyright 2008 Google Inc. All rights reserved. 3 | // https://developers.google.com/protocol-buffers/ 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are 7 | // met: 8 | // 9 | // * Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // * Redistributions in binary form must reproduce the above 12 | // copyright notice, this list of conditions and the following disclaimer 13 | // in the documentation and/or other materials provided with the 14 | // distribution. 15 | // * Neither the name of Google Inc. nor the names of its 16 | // contributors may be used to endorse or promote products derived from 17 | // this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | #include 32 | 33 | #include 34 | 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | namespace duckdb{ 42 | 43 | namespace google { 44 | namespace protobuf { 45 | namespace internal { 46 | 47 | namespace { 48 | 49 | UnknownFieldSet* MutableUnknownFields(MessageLite* msg, int64_t arena_offset) { 50 | return Raw(msg, arena_offset) 51 | ->mutable_unknown_fields(); 52 | } 53 | 54 | struct UnknownFieldHandler { 55 | // TODO(mvels): consider renaming UnknownFieldHandler to (TableDrivenTraits?), 56 | // and conflating InternalMetaData into it, simplifying the template. 57 | static constexpr bool IsLite() { return false; } 58 | 59 | static bool Skip(MessageLite* msg, const ParseTable& table, 60 | io::CodedInputStream* input, int tag) { 61 | GOOGLE_DCHECK(table.unknown_field_set); 62 | 63 | return WireFormat::SkipField(input, tag, 64 | MutableUnknownFields(msg, table.arena_offset)); 65 | } 66 | 67 | static void Varint(MessageLite* msg, const ParseTable& table, int tag, 68 | int value) { 69 | GOOGLE_DCHECK(table.unknown_field_set); 70 | 71 | MutableUnknownFields(msg, table.arena_offset) 72 | ->AddVarint(WireFormatLite::GetTagFieldNumber(tag), value); 73 | } 74 | 75 | static bool ParseExtension(MessageLite* msg, const ParseTable& table, 76 | io::CodedInputStream* input, int tag) { 77 | ExtensionSet* extensions = GetExtensionSet(msg, table.extension_offset); 78 | if (extensions == nullptr) { 79 | return false; 80 | } 81 | 82 | const Message* prototype = 83 | down_cast(table.default_instance()); 84 | 85 | GOOGLE_DCHECK(prototype != nullptr); 86 | GOOGLE_DCHECK(table.unknown_field_set); 87 | UnknownFieldSet* unknown_fields = 88 | MutableUnknownFields(msg, table.arena_offset); 89 | 90 | return extensions->ParseField(tag, input, prototype, unknown_fields); 91 | } 92 | }; 93 | 94 | } // namespace 95 | 96 | bool MergePartialFromCodedStream(MessageLite* msg, const ParseTable& table, 97 | io::CodedInputStream* input) { 98 | return MergePartialFromCodedStreamImpl(msg, table, 99 | input); 100 | } 101 | 102 | } // namespace internal 103 | } // namespace protobuf 104 | } // namespace google 105 | } // namespace duckdb -------------------------------------------------------------------------------- /third_party/google/protobuf/generated_message_table_driven_lite.cc: -------------------------------------------------------------------------------- 1 | // Protocol Buffers - Google's data interchange format 2 | // Copyright 2008 Google Inc. All rights reserved. 3 | // https://developers.google.com/protocol-buffers/ 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are 7 | // met: 8 | // 9 | // * Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // * Redistributions in binary form must reproduce the above 12 | // copyright notice, this list of conditions and the following disclaimer 13 | // in the documentation and/or other materials provided with the 14 | // distribution. 15 | // * Neither the name of Google Inc. nor the names of its 16 | // contributors may be used to endorse or promote products derived from 17 | // this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | #include 32 | 33 | #include 34 | 35 | #include 36 | #include 37 | #include 38 | #include 39 | namespace duckdb { 40 | namespace google { 41 | namespace protobuf { 42 | namespace internal { 43 | 44 | namespace { 45 | 46 | std::string *MutableUnknownFields(MessageLite *msg, int64_t arena_offset) { 47 | return Raw(msg, arena_offset)->mutable_unknown_fields(); 48 | } 49 | 50 | struct UnknownFieldHandlerLite { 51 | // TODO(mvels): consider renaming UnknownFieldHandler to (TableDrivenTraits?), 52 | // and conflating InternalMetaData into it, simplifying the template. 53 | static constexpr bool IsLite() { 54 | return true; 55 | } 56 | 57 | static bool Skip(MessageLite *msg, const ParseTable &table, io::CodedInputStream *input, int tag) { 58 | GOOGLE_DCHECK(!table.unknown_field_set); 59 | io::StringOutputStream unknown_fields_string(MutableUnknownFields(msg, table.arena_offset)); 60 | io::CodedOutputStream unknown_fields_stream(&unknown_fields_string, false); 61 | 62 | return internal::WireFormatLite::SkipField(input, tag, &unknown_fields_stream); 63 | } 64 | 65 | static void Varint(MessageLite *msg, const ParseTable &table, int tag, int value) { 66 | GOOGLE_DCHECK(!table.unknown_field_set); 67 | 68 | io::StringOutputStream unknown_fields_string(MutableUnknownFields(msg, table.arena_offset)); 69 | io::CodedOutputStream unknown_fields_stream(&unknown_fields_string, false); 70 | unknown_fields_stream.WriteVarint32(tag); 71 | unknown_fields_stream.WriteVarint32(value); 72 | } 73 | 74 | static bool ParseExtension(MessageLite *msg, const ParseTable &table, io::CodedInputStream *input, int tag) { 75 | ExtensionSet *extensions = GetExtensionSet(msg, table.extension_offset); 76 | if (extensions == nullptr) { 77 | return false; 78 | } 79 | 80 | const MessageLite *prototype = table.default_instance(); 81 | 82 | GOOGLE_DCHECK(!table.unknown_field_set); 83 | io::StringOutputStream unknown_fields_string(MutableUnknownFields(msg, table.arena_offset)); 84 | io::CodedOutputStream unknown_fields_stream(&unknown_fields_string, false); 85 | return extensions->ParseField(tag, input, prototype, &unknown_fields_stream); 86 | } 87 | }; 88 | 89 | } // namespace 90 | 91 | bool MergePartialFromCodedStreamLite(MessageLite *msg, const ParseTable &table, io::CodedInputStream *input) { 92 | return MergePartialFromCodedStreamImpl(msg, table, input); 93 | } 94 | 95 | } // namespace internal 96 | } // namespace protobuf 97 | } // namespace google 98 | } // namespace duckdb -------------------------------------------------------------------------------- /third_party/google/protobuf/has_bits.h: -------------------------------------------------------------------------------- 1 | // Protocol Buffers - Google's data interchange format 2 | // Copyright 2008 Google Inc. All rights reserved. 3 | // https://developers.google.com/protocol-buffers/ 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are 7 | // met: 8 | // 9 | // * Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // * Redistributions in binary form must reproduce the above 12 | // copyright notice, this list of conditions and the following disclaimer 13 | // in the documentation and/or other materials provided with the 14 | // distribution. 15 | // * Neither the name of Google Inc. nor the names of its 16 | // contributors may be used to endorse or promote products derived from 17 | // this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | #ifndef GOOGLE_PROTOBUF_HAS_BITS_H__ 32 | #define GOOGLE_PROTOBUF_HAS_BITS_H__ 33 | 34 | #include 35 | #include 36 | 37 | #include 38 | 39 | #ifdef SWIG 40 | #error "You cannot SWIG proto headers" 41 | #endif 42 | namespace duckdb { 43 | namespace google { 44 | namespace protobuf { 45 | namespace internal { 46 | 47 | template 48 | class HasBits { 49 | public: 50 | PROTOBUF_NDEBUG_INLINE constexpr HasBits() : has_bits_ {} { 51 | } 52 | 53 | PROTOBUF_NDEBUG_INLINE void Clear() { 54 | memset(has_bits_, 0, sizeof(has_bits_)); 55 | } 56 | 57 | PROTOBUF_NDEBUG_INLINE uint32_t &operator[](int index) { 58 | return has_bits_[index]; 59 | } 60 | 61 | PROTOBUF_NDEBUG_INLINE const uint32_t &operator[](int index) const { 62 | return has_bits_[index]; 63 | } 64 | 65 | bool operator==(const HasBits &rhs) const { 66 | return memcmp(has_bits_, rhs.has_bits_, sizeof(has_bits_)) == 0; 67 | } 68 | 69 | bool operator!=(const HasBits &rhs) const { 70 | return !(*this == rhs); 71 | } 72 | 73 | void Or(const HasBits &rhs) { 74 | for (size_t i = 0; i < doublewords; i++) 75 | has_bits_[i] |= rhs[i]; 76 | } 77 | 78 | bool empty() const; 79 | 80 | private: 81 | uint32_t has_bits_[doublewords]; 82 | }; 83 | 84 | template <> 85 | inline bool HasBits<1>::empty() const { 86 | return !has_bits_[0]; 87 | } 88 | 89 | template <> 90 | inline bool HasBits<2>::empty() const { 91 | return !(has_bits_[0] | has_bits_[1]); 92 | } 93 | 94 | template <> 95 | inline bool HasBits<3>::empty() const { 96 | return !(has_bits_[0] | has_bits_[1] | has_bits_[2]); 97 | } 98 | 99 | template <> 100 | inline bool HasBits<4>::empty() const { 101 | return !(has_bits_[0] | has_bits_[1] | has_bits_[2] | has_bits_[3]); 102 | } 103 | 104 | template 105 | inline bool HasBits::empty() const { 106 | for (size_t i = 0; i < doublewords; ++i) { 107 | if (has_bits_[i]) 108 | return false; 109 | } 110 | return true; 111 | } 112 | 113 | } // namespace internal 114 | } // namespace protobuf 115 | } // namespace google 116 | } // namespace duckdb 117 | #include 118 | 119 | #endif // GOOGLE_PROTOBUF_HAS_BITS_H__ 120 | -------------------------------------------------------------------------------- /third_party/google/protobuf/implicit_weak_message.cc: -------------------------------------------------------------------------------- 1 | // Protocol Buffers - Google's data interchange format 2 | // Copyright 2008 Google Inc. All rights reserved. 3 | // https://developers.google.com/protocol-buffers/ 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are 7 | // met: 8 | // 9 | // * Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // * Redistributions in binary form must reproduce the above 12 | // copyright notice, this list of conditions and the following disclaimer 13 | // in the documentation and/or other materials provided with the 14 | // distribution. 15 | // * Neither the name of Google Inc. nor the names of its 16 | // contributors may be used to endorse or promote products derived from 17 | // this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | #include 32 | 33 | #include 34 | #include 35 | #include 36 | #include 37 | 38 | #include 39 | 40 | namespace duckdb { 41 | namespace google { 42 | namespace protobuf { 43 | namespace internal { 44 | 45 | const char *ImplicitWeakMessage::_InternalParse(const char *ptr, ParseContext *ctx) { 46 | return ctx->AppendString(ptr, &data_); 47 | } 48 | 49 | ExplicitlyConstructed implicit_weak_message_default_instance; 50 | internal::once_flag implicit_weak_message_once_init_; 51 | 52 | void InitImplicitWeakMessageDefaultInstance() { 53 | implicit_weak_message_default_instance.DefaultConstruct(); 54 | } 55 | 56 | const ImplicitWeakMessage *ImplicitWeakMessage::default_instance() { 57 | internal::call_once(implicit_weak_message_once_init_, InitImplicitWeakMessageDefaultInstance); 58 | return &implicit_weak_message_default_instance.get(); 59 | } 60 | 61 | } // namespace internal 62 | } // namespace protobuf 63 | } // namespace google 64 | } //namespace duckdb 65 | #include 66 | -------------------------------------------------------------------------------- /third_party/google/protobuf/inlined_string_field.cc: -------------------------------------------------------------------------------- 1 | // Protocol Buffers - Google's data interchange format 2 | // Copyright 2008 Google Inc. All rights reserved. 3 | // https://developers.google.com/protocol-buffers/ 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are 7 | // met: 8 | // 9 | // * Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // * Redistributions in binary form must reproduce the above 12 | // copyright notice, this list of conditions and the following disclaimer 13 | // in the documentation and/or other materials provided with the 14 | // distribution. 15 | // * Neither the name of Google Inc. nor the names of its 16 | // contributors may be used to endorse or promote products derived from 17 | // this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | #include 32 | 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | 39 | // clang-format off 40 | #include 41 | // clang-format on 42 | namespace duckdb { 43 | namespace google { 44 | namespace protobuf { 45 | namespace internal { 46 | 47 | std::string *InlinedStringField::Mutable(const LazyString & /*default_value*/, Arena *arena, bool donated, 48 | uint32_t *donating_states, uint32_t mask) { 49 | if (arena == nullptr || !donated) { 50 | return UnsafeMutablePointer(); 51 | } 52 | return MutableSlow(arena, donated, donating_states, mask); 53 | } 54 | 55 | std::string *InlinedStringField::Mutable(ArenaStringPtr::EmptyDefault, Arena *arena, bool donated, 56 | uint32_t *donating_states, uint32_t mask) { 57 | if (arena == nullptr || !donated) { 58 | return UnsafeMutablePointer(); 59 | } 60 | return MutableSlow(arena, donated, donating_states, mask); 61 | } 62 | 63 | std::string *InlinedStringField::MutableSlow(duckdb::google::protobuf::Arena *arena, bool donated, 64 | uint32_t *donating_states, uint32_t mask) { 65 | return UnsafeMutablePointer(); 66 | } 67 | 68 | void InlinedStringField::SetAllocated(const std::string *default_value, std::string *value, Arena *arena, bool donated, 69 | uint32_t *donating_states, uint32_t mask) { 70 | SetAllocatedNoArena(default_value, value); 71 | } 72 | 73 | void InlinedStringField::Set(const std::string *default_value, std::string &&value, Arena *arena, bool donated, 74 | uint32_t *donating_states, uint32_t mask) { 75 | SetNoArena(default_value, std::move(value)); 76 | } 77 | 78 | std::string *InlinedStringField::Release(const std::string *default_value, Arena *arena, bool donated) { 79 | if (arena == nullptr && !donated) { 80 | return ReleaseNonDefaultNoArena(default_value); 81 | } 82 | return ReleaseNonDefault(default_value, arena); 83 | } 84 | 85 | std::string *InlinedStringField::ReleaseNonDefault(const std::string *default_value, Arena *arena) { 86 | return ReleaseNonDefaultNoArena(default_value); 87 | } 88 | 89 | void InlinedStringField::ClearToDefault(const LazyString &default_value, Arena *arena, bool donated) { 90 | (void)arena; 91 | get_mutable()->assign(default_value.get()); 92 | } 93 | 94 | } // namespace internal 95 | } // namespace protobuf 96 | } // namespace google 97 | } //namespace duckdb -------------------------------------------------------------------------------- /third_party/google/protobuf/io/strtod.cc: -------------------------------------------------------------------------------- 1 | // Protocol Buffers - Google's data interchange format 2 | // Copyright 2008 Google Inc. All rights reserved. 3 | // https://developers.google.com/protocol-buffers/ 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are 7 | // met: 8 | // 9 | // * Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // * Redistributions in binary form must reproduce the above 12 | // copyright notice, this list of conditions and the following disclaimer 13 | // in the documentation and/or other materials provided with the 14 | // distribution. 15 | // * Neither the name of Google Inc. nor the names of its 16 | // contributors may be used to endorse or promote products derived from 17 | // this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | #include 32 | 33 | #include 34 | #include 35 | #include 36 | #include 37 | 38 | #include 39 | #include 40 | 41 | #include 42 | namespace duckdb { 43 | namespace google { 44 | namespace protobuf { 45 | namespace io { 46 | 47 | // This approximately 0x1.ffffffp127, but we don't use 0x1.ffffffp127 because 48 | // it won't compile in MSVC. 49 | const double MAX_FLOAT_AS_DOUBLE_ROUNDED = 3.4028235677973366e+38; 50 | 51 | float SafeDoubleToFloat(double value) { 52 | // static_cast on a number larger than float can result in illegal 53 | // instruction error, so we need to manually convert it to infinity or max. 54 | if (value > std::numeric_limits::max()) { 55 | // Max float value is about 3.4028234664E38 when represented as a double. 56 | // However, when printing float as text, it will be rounded as 57 | // 3.4028235e+38. If we parse the value of 3.4028235e+38 from text and 58 | // compare it to 3.4028234664E38, we may think that it is larger, but 59 | // actually, any number between these two numbers could only be represented 60 | // as the same max float number in float, so we should treat them the same 61 | // as max float. 62 | if (value <= MAX_FLOAT_AS_DOUBLE_ROUNDED) { 63 | return std::numeric_limits::max(); 64 | } 65 | return std::numeric_limits::infinity(); 66 | } else if (value < -std::numeric_limits::max()) { 67 | if (value >= -MAX_FLOAT_AS_DOUBLE_ROUNDED) { 68 | return -std::numeric_limits::max(); 69 | } 70 | return -std::numeric_limits::infinity(); 71 | } else { 72 | return static_cast(value); 73 | } 74 | } 75 | 76 | double NoLocaleStrtod(const char *str, char **endptr) { 77 | return google::protobuf::internal::NoLocaleStrtod(str, endptr); 78 | } 79 | 80 | } // namespace io 81 | } // namespace protobuf 82 | } // namespace google 83 | } //namespace duckdb -------------------------------------------------------------------------------- /third_party/google/protobuf/io/strtod.h: -------------------------------------------------------------------------------- 1 | // Protocol Buffers - Google's data interchange format 2 | // Copyright 2008 Google Inc. All rights reserved. 3 | // https://developers.google.com/protocol-buffers/ 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are 7 | // met: 8 | // 9 | // * Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // * Redistributions in binary form must reproduce the above 12 | // copyright notice, this list of conditions and the following disclaimer 13 | // in the documentation and/or other materials provided with the 14 | // distribution. 15 | // * Neither the name of Google Inc. nor the names of its 16 | // contributors may be used to endorse or promote products derived from 17 | // this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | // A locale-independent version of strtod(), used to parse floating 32 | // point default values in .proto files, where the decimal separator 33 | // is always a dot. 34 | 35 | #ifndef GOOGLE_PROTOBUF_IO_STRTOD_H__ 36 | #define GOOGLE_PROTOBUF_IO_STRTOD_H__ 37 | namespace duckdb { 38 | namespace google { 39 | namespace protobuf { 40 | namespace io { 41 | 42 | // A locale-independent version of the standard strtod(), which always 43 | // uses a dot as the decimal separator. 44 | double NoLocaleStrtod(const char *str, char **endptr); 45 | 46 | // Casts a double value to a float value. If the value is outside of the 47 | // representable range of float, it will be converted to positive or negative 48 | // infinity. 49 | float SafeDoubleToFloat(double value); 50 | 51 | } // namespace io 52 | } // namespace protobuf 53 | } // namespace google 54 | } //namespace duckdb 55 | #endif // GOOGLE_PROTOBUF_IO_STRTOD_H__ 56 | -------------------------------------------------------------------------------- /third_party/google/protobuf/io/zero_copy_stream.cc: -------------------------------------------------------------------------------- 1 | // Protocol Buffers - Google's data interchange format 2 | // Copyright 2008 Google Inc. All rights reserved. 3 | // https://developers.google.com/protocol-buffers/ 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are 7 | // met: 8 | // 9 | // * Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // * Redistributions in binary form must reproduce the above 12 | // copyright notice, this list of conditions and the following disclaimer 13 | // in the documentation and/or other materials provided with the 14 | // distribution. 15 | // * Neither the name of Google Inc. nor the names of its 16 | // contributors may be used to endorse or promote products derived from 17 | // this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | // Author: kenton@google.com (Kenton Varda) 32 | // Based on original Protocol Buffers design by 33 | // Sanjay Ghemawat, Jeff Dean, and others. 34 | 35 | #include 36 | 37 | #include 38 | #include 39 | 40 | namespace duckdb { 41 | namespace google { 42 | namespace protobuf { 43 | namespace io { 44 | 45 | bool ZeroCopyOutputStream::WriteAliasedRaw(const void * /* data */, int /* size */) { 46 | GOOGLE_LOG(FATAL) << "This ZeroCopyOutputStream doesn't support aliasing. " 47 | "Reaching here usually means a ZeroCopyOutputStream " 48 | "implementation bug."; 49 | return false; 50 | } 51 | 52 | } // namespace io 53 | } // namespace protobuf 54 | } // namespace google 55 | } //namespace duckdb -------------------------------------------------------------------------------- /third_party/google/protobuf/map.cc: -------------------------------------------------------------------------------- 1 | // Protocol Buffers - Google's data interchange format 2 | // Copyright 2008 Google Inc. All rights reserved. 3 | // https://developers.google.com/protocol-buffers/ 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are 7 | // met: 8 | // 9 | // * Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // * Redistributions in binary form must reproduce the above 12 | // copyright notice, this list of conditions and the following disclaimer 13 | // in the documentation and/or other materials provided with the 14 | // distribution. 15 | // * Neither the name of Google Inc. nor the names of its 16 | // contributors may be used to endorse or promote products derived from 17 | // this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | #include 32 | namespace duckdb { 33 | namespace google { 34 | namespace protobuf { 35 | namespace internal { 36 | 37 | void *const kGlobalEmptyTable[kGlobalEmptyTableSize] = {nullptr}; 38 | 39 | } // namespace internal 40 | } // namespace protobuf 41 | } // namespace google 42 | } //namespace duckdb -------------------------------------------------------------------------------- /third_party/google/protobuf/port.h: -------------------------------------------------------------------------------- 1 | // Protocol Buffers - Google's data interchange format 2 | // Copyright 2008 Google Inc. All rights reserved. 3 | // https://developers.google.com/protocol-buffers/ 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are 7 | // met: 8 | // 9 | // * Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // * Redistributions in binary form must reproduce the above 12 | // copyright notice, this list of conditions and the following disclaimer 13 | // in the documentation and/or other materials provided with the 14 | // distribution. 15 | // * Neither the name of Google Inc. nor the names of its 16 | // contributors may be used to endorse or promote products derived from 17 | // this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | // A common header that is included across all protobuf headers. We do our best 32 | // to avoid #defining any macros here; instead we generally put macros in 33 | // port_def.inc and port_undef.inc so they are not visible from outside of 34 | // protobuf. 35 | 36 | #ifndef GOOGLE_PROTOBUF_PORT_H__ 37 | #define GOOGLE_PROTOBUF_PORT_H__ 38 | 39 | 40 | #endif // GOOGLE_PROTOBUF_PORT_H__ 41 | -------------------------------------------------------------------------------- /third_party/google/protobuf/reflection_ops.h: -------------------------------------------------------------------------------- 1 | // Protocol Buffers - Google's data interchange format 2 | // Copyright 2008 Google Inc. All rights reserved. 3 | // https://developers.google.com/protocol-buffers/ 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are 7 | // met: 8 | // 9 | // * Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // * Redistributions in binary form must reproduce the above 12 | // copyright notice, this list of conditions and the following disclaimer 13 | // in the documentation and/or other materials provided with the 14 | // distribution. 15 | // * Neither the name of Google Inc. nor the names of its 16 | // contributors may be used to endorse or promote products derived from 17 | // this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | // Author: kenton@google.com (Kenton Varda) 32 | // Based on original Protocol Buffers design by 33 | // Sanjay Ghemawat, Jeff Dean, and others. 34 | // 35 | // This header is logically internal, but is made public because it is used 36 | // from protocol-compiler-generated code, which may reside in other components. 37 | 38 | #ifndef GOOGLE_PROTOBUF_REFLECTION_OPS_H__ 39 | #define GOOGLE_PROTOBUF_REFLECTION_OPS_H__ 40 | 41 | #include 42 | #include 43 | 44 | #ifdef SWIG 45 | #error "You cannot SWIG proto headers" 46 | #endif 47 | 48 | #include 49 | namespace duckdb { 50 | namespace google { 51 | namespace protobuf { 52 | namespace internal { 53 | 54 | // Basic operations that can be performed using reflection. 55 | // These can be used as a cheap way to implement the corresponding 56 | // methods of the Message interface, though they are likely to be 57 | // slower than implementations tailored for the specific message type. 58 | // 59 | // This class should stay limited to operations needed to implement 60 | // the Message interface. 61 | // 62 | // This class is really a namespace that contains only static methods. 63 | class ReflectionOps { 64 | public: 65 | static void Copy(const Message &from, Message *to); 66 | static void Merge(const Message &from, Message *to); 67 | static void Clear(Message *message); 68 | static bool IsInitialized(const Message &message); 69 | static bool IsInitialized(const Message &message, bool check_fields, bool check_descendants); 70 | static void DiscardUnknownFields(Message *message); 71 | 72 | // Finds all unset required fields in the message and adds their full 73 | // paths (e.g. "foo.bar[5].baz") to *names. "prefix" will be attached to 74 | // the front of each name. 75 | static void FindInitializationErrors(const Message &message, const std::string &prefix, 76 | std::vector *errors); 77 | 78 | private: 79 | // All methods are static. No need to construct. 80 | GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ReflectionOps); 81 | }; 82 | 83 | } // namespace internal 84 | } // namespace protobuf 85 | } // namespace google 86 | } //namespace duckdb 87 | #include 88 | 89 | #endif // GOOGLE_PROTOBUF_REFLECTION_OPS_H__ 90 | -------------------------------------------------------------------------------- /third_party/google/protobuf/repeated_field.cc: -------------------------------------------------------------------------------- 1 | // Protocol Buffers - Google's data interchange format 2 | // Copyright 2008 Google Inc. All rights reserved. 3 | // https://developers.google.com/protocol-buffers/ 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are 7 | // met: 8 | // 9 | // * Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // * Redistributions in binary form must reproduce the above 12 | // copyright notice, this list of conditions and the following disclaimer 13 | // in the documentation and/or other materials provided with the 14 | // distribution. 15 | // * Neither the name of Google Inc. nor the names of its 16 | // contributors may be used to endorse or promote products derived from 17 | // this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | // Author: kenton@google.com (Kenton Varda) 32 | // Based on original Protocol Buffers design by 33 | // Sanjay Ghemawat, Jeff Dean, and others. 34 | 35 | #include 36 | 37 | #include 38 | 39 | #include 40 | #include 41 | 42 | #include 43 | 44 | namespace duckdb { 45 | namespace google { 46 | namespace protobuf { 47 | 48 | template class RepeatedField; 49 | template class RepeatedField; 50 | template class RepeatedField; 51 | template class RepeatedField; 52 | template class RepeatedField; 53 | template class RepeatedField; 54 | template class RepeatedField; 55 | template class RepeatedPtrField; 56 | 57 | } // namespace protobuf 58 | } // namespace google 59 | } //namespace duckdb 60 | #include 61 | -------------------------------------------------------------------------------- /third_party/google/protobuf/stubs/hash.h: -------------------------------------------------------------------------------- 1 | // Protocol Buffers - Google's data interchange format 2 | // Copyright 2008 Google Inc. All rights reserved. 3 | // https://developers.google.com/protocol-buffers/ 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are 7 | // met: 8 | // 9 | // * Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // * Redistributions in binary form must reproduce the above 12 | // copyright notice, this list of conditions and the following disclaimer 13 | // in the documentation and/or other materials provided with the 14 | // distribution. 15 | // * Neither the name of Google Inc. nor the names of its 16 | // contributors may be used to endorse or promote products derived from 17 | // this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | // Author: kenton@google.com (Kenton Varda) 32 | 33 | #ifndef GOOGLE_PROTOBUF_STUBS_HASH_H__ 34 | #define GOOGLE_PROTOBUF_STUBS_HASH_H__ 35 | 36 | #include 37 | #include 38 | #include 39 | #include 40 | 41 | # define GOOGLE_PROTOBUF_HASH_NAMESPACE_DECLARATION_START \ 42 | namespace duckdb{ \ 43 | namespace google { \ 44 | namespace protobuf { 45 | # define GOOGLE_PROTOBUF_HASH_NAMESPACE_DECLARATION_END }}} 46 | 47 | namespace duckdb { 48 | namespace google { 49 | namespace protobuf { 50 | 51 | template 52 | struct hash : public std::hash {}; 53 | 54 | template 55 | struct hash { 56 | inline size_t operator()(const Key *key) const { 57 | return reinterpret_cast(key); 58 | } 59 | }; 60 | 61 | // Unlike the old SGI version, the TR1 "hash" does not special-case char*. So, 62 | // we go ahead and provide our own implementation. 63 | template <> 64 | struct hash { 65 | inline size_t operator()(const char *str) const { 66 | size_t result = 0; 67 | for (; *str != '\0'; str++) { 68 | result = 5 * result + static_cast(*str); 69 | } 70 | return result; 71 | } 72 | }; 73 | 74 | template <> 75 | struct hash { 76 | size_t operator()(bool x) const { 77 | return static_cast(x); 78 | } 79 | }; 80 | 81 | template <> 82 | struct hash { 83 | inline size_t operator()(const std::string &key) const { 84 | return hash()(key.c_str()); 85 | } 86 | 87 | static const size_t bucket_size = 4; 88 | static const size_t min_buckets = 8; 89 | inline bool operator()(const std::string &a, const std::string &b) const { 90 | return a < b; 91 | } 92 | }; 93 | 94 | template 95 | struct hash> { 96 | inline size_t operator()(const std::pair &key) const { 97 | size_t first_hash = hash()(key.first); 98 | size_t second_hash = hash()(key.second); 99 | 100 | // FIXME(kenton): What is the best way to compute this hash? I have 101 | // no idea! This seems a bit better than an XOR. 102 | return first_hash * ((1 << 16) - 1) + second_hash; 103 | } 104 | 105 | static const size_t bucket_size = 4; 106 | static const size_t min_buckets = 8; 107 | inline bool operator()(const std::pair &a, const std::pair &b) const { 108 | return a < b; 109 | } 110 | }; 111 | 112 | } // namespace protobuf 113 | } // namespace google 114 | } //namespace duckdb 115 | #endif // GOOGLE_PROTOBUF_STUBS_HASH_H__ 116 | -------------------------------------------------------------------------------- /third_party/google/protobuf/stubs/macros.h: -------------------------------------------------------------------------------- 1 | // Protocol Buffers - Google's data interchange format 2 | // Copyright 2008 Google Inc. All rights reserved. 3 | // https://developers.google.com/protocol-buffers/ 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are 7 | // met: 8 | // 9 | // * Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // * Redistributions in binary form must reproduce the above 12 | // copyright notice, this list of conditions and the following disclaimer 13 | // in the documentation and/or other materials provided with the 14 | // distribution. 15 | // * Neither the name of Google Inc. nor the names of its 16 | // contributors may be used to endorse or promote products derived from 17 | // this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | #ifndef GOOGLE_PROTOBUF_MACROS_H__ 32 | #define GOOGLE_PROTOBUF_MACROS_H__ 33 | namespace duckdb { 34 | namespace google { 35 | namespace protobuf { 36 | 37 | #undef GOOGLE_DISALLOW_EVIL_CONSTRUCTORS 38 | #define GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(TypeName) \ 39 | TypeName(const TypeName &) = delete; \ 40 | void operator=(const TypeName &) = delete 41 | 42 | #undef GOOGLE_DISALLOW_IMPLICIT_CONSTRUCTORS 43 | #define GOOGLE_DISALLOW_IMPLICIT_CONSTRUCTORS(TypeName) \ 44 | TypeName() = delete; \ 45 | TypeName(const TypeName &) = delete; \ 46 | void operator=(const TypeName &) = delete 47 | 48 | // =================================================================== 49 | // from google3/base/basictypes.h 50 | 51 | // The GOOGLE_ARRAYSIZE(arr) macro returns the # of elements in an array arr. 52 | // The expression is a compile-time constant, and therefore can be 53 | // used in defining new arrays, for example. 54 | // 55 | // GOOGLE_ARRAYSIZE catches a few type errors. If you see a compiler error 56 | // 57 | // "warning: division by zero in ..." 58 | // 59 | // when using GOOGLE_ARRAYSIZE, you are (wrongfully) giving it a pointer. 60 | // You should only use GOOGLE_ARRAYSIZE on statically allocated arrays. 61 | // 62 | // The following comments are on the implementation details, and can 63 | // be ignored by the users. 64 | // 65 | // ARRAYSIZE(arr) works by inspecting sizeof(arr) (the # of bytes in 66 | // the array) and sizeof(*(arr)) (the # of bytes in one array 67 | // element). If the former is divisible by the latter, perhaps arr is 68 | // indeed an array, in which case the division result is the # of 69 | // elements in the array. Otherwise, arr cannot possibly be an array, 70 | // and we generate a compiler error to prevent the code from 71 | // compiling. 72 | // 73 | // Since the size of bool is implementation-defined, we need to cast 74 | // !(sizeof(a) & sizeof(*(a))) to size_t in order to ensure the final 75 | // result has type size_t. 76 | // 77 | // This macro is not perfect as it wrongfully accepts certain 78 | // pointers, namely where the pointer size is divisible by the pointee 79 | // size. Since all our code has to go through a 32-bit compiler, 80 | // where a pointer is 4 bytes, this means all pointers to a type whose 81 | // size is 3 or greater than 4 will be (righteously) rejected. 82 | // 83 | // Kudos to Jorg Brown for this simple and elegant implementation. 84 | 85 | #undef GOOGLE_ARRAYSIZE 86 | #define GOOGLE_ARRAYSIZE(a) ((sizeof(a) / sizeof(*(a))) / static_cast(!(sizeof(a) % sizeof(*(a))))) 87 | 88 | } // namespace protobuf 89 | } // namespace google 90 | } //namespace duckdb 91 | #endif // GOOGLE_PROTOBUF_MACROS_H__ 92 | -------------------------------------------------------------------------------- /third_party/google/protobuf/stubs/once.h: -------------------------------------------------------------------------------- 1 | // Protocol Buffers - Google's data interchange format 2 | // Copyright 2008 Google Inc. All rights reserved. 3 | // https://developers.google.com/protocol-buffers/ 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are 7 | // met: 8 | // 9 | // * Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // * Redistributions in binary form must reproduce the above 12 | // copyright notice, this list of conditions and the following disclaimer 13 | // in the documentation and/or other materials provided with the 14 | // distribution. 15 | // * Neither the name of Google Inc. nor the names of its 16 | // contributors may be used to endorse or promote products derived from 17 | // this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | #ifndef GOOGLE_PROTOBUF_STUBS_ONCE_H__ 32 | #define GOOGLE_PROTOBUF_STUBS_ONCE_H__ 33 | 34 | #include 35 | #include 36 | 37 | #include 38 | namespace duckdb { 39 | namespace google { 40 | namespace protobuf { 41 | namespace internal { 42 | 43 | using once_flag = std::once_flag; 44 | template 45 | void call_once(Args &&...args) { 46 | std::call_once(std::forward(args)...); 47 | } 48 | 49 | } // namespace internal 50 | } // namespace protobuf 51 | } // namespace google 52 | } //namespace duckdb 53 | #include 54 | 55 | #endif // GOOGLE_PROTOBUF_STUBS_ONCE_H__ 56 | -------------------------------------------------------------------------------- /third_party/google/protobuf/stubs/status_macros.h: -------------------------------------------------------------------------------- 1 | // Protocol Buffers - Google's data interchange format 2 | // Copyright 2008 Google Inc. All rights reserved. 3 | // https://developers.google.com/protocol-buffers/ 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are 7 | // met: 8 | // 9 | // * Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // * Redistributions in binary form must reproduce the above 12 | // copyright notice, this list of conditions and the following disclaimer 13 | // in the documentation and/or other materials provided with the 14 | // distribution. 15 | // * Neither the name of Google Inc. nor the names of its 16 | // contributors may be used to endorse or promote products derived from 17 | // this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | // From: util/task/contrib/status_macros/status_macros.h 32 | 33 | #ifndef GOOGLE_PROTOBUF_STUBS_STATUS_MACROS_H_ 34 | #define GOOGLE_PROTOBUF_STUBS_STATUS_MACROS_H_ 35 | 36 | #include 37 | #include 38 | #include 39 | namespace duckdb { 40 | namespace google { 41 | namespace protobuf { 42 | namespace util { 43 | 44 | // Run a command that returns a util::Status. If the called code returns an 45 | // error status, return that status up out of this method too. 46 | // 47 | // Example: 48 | // RETURN_IF_ERROR(DoThings(4)); 49 | #define RETURN_IF_ERROR(expr) \ 50 | do { \ 51 | /* Using _status below to avoid capture problems if expr is "status". */ \ 52 | const PROTOBUF_NAMESPACE_ID::util::Status _status = (expr); \ 53 | if (PROTOBUF_PREDICT_FALSE(!_status.ok())) return _status; \ 54 | } while (0) 55 | 56 | // Internal helper for concatenating macro values. 57 | #define STATUS_MACROS_CONCAT_NAME_INNER(x, y) x##y 58 | #define STATUS_MACROS_CONCAT_NAME(x, y) STATUS_MACROS_CONCAT_NAME_INNER(x, y) 59 | 60 | template 61 | Status DoAssignOrReturn(T &lhs, StatusOr result) { 62 | if (result.ok()) { 63 | lhs = result.value(); 64 | } 65 | return result.status(); 66 | } 67 | 68 | #define ASSIGN_OR_RETURN_IMPL(status, lhs, rexpr) \ 69 | Status status = DoAssignOrReturn(lhs, (rexpr)); \ 70 | if (PROTOBUF_PREDICT_FALSE(!status.ok())) return status; 71 | 72 | // Executes an expression that returns a util::StatusOr, extracting its value 73 | // into the variable defined by lhs (or returning on error). 74 | // 75 | // Example: Assigning to an existing value 76 | // ValueType value; 77 | // ASSIGN_OR_RETURN(value, MaybeGetValue(arg)); 78 | // 79 | // WARNING: ASSIGN_OR_RETURN expands into multiple statements; it cannot be used 80 | // in a single statement (e.g. as the body of an if statement without {})! 81 | #define ASSIGN_OR_RETURN(lhs, rexpr) \ 82 | ASSIGN_OR_RETURN_IMPL(STATUS_MACROS_CONCAT_NAME(_status_or_value, __COUNTER__), lhs, rexpr); 83 | 84 | } // namespace util 85 | } // namespace protobuf 86 | } // namespace google 87 | } 88 | #endif // GOOGLE_PROTOBUF_STUBS_STATUS_H_ 89 | -------------------------------------------------------------------------------- /third_party/google/protobuf/stubs/statusor.cc: -------------------------------------------------------------------------------- 1 | // Protocol Buffers - Google's data interchange format 2 | // Copyright 2008 Google Inc. All rights reserved. 3 | // https://developers.google.com/protocol-buffers/ 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are 7 | // met: 8 | // 9 | // * Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // * Redistributions in binary form must reproduce the above 12 | // copyright notice, this list of conditions and the following disclaimer 13 | // in the documentation and/or other materials provided with the 14 | // distribution. 15 | // * Neither the name of Google Inc. nor the names of its 16 | // contributors may be used to endorse or promote products derived from 17 | // this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | #include 32 | 33 | #include 34 | namespace duckdb { 35 | namespace google { 36 | namespace protobuf { 37 | namespace util { 38 | namespace statusor_internal { 39 | 40 | void StatusOrHelper::Crash(const Status &status) { 41 | GOOGLE_LOG(FATAL) << "Attempting to fetch value instead of handling error " << status.ToString(); 42 | } 43 | 44 | } // namespace statusor_internal 45 | } // namespace util 46 | } // namespace protobuf 47 | } // namespace google 48 | } -------------------------------------------------------------------------------- /third_party/google/protobuf/stubs/stl_util.h: -------------------------------------------------------------------------------- 1 | // Protocol Buffers - Google's data interchange format 2 | // Copyright 2008 Google Inc. All rights reserved. 3 | // https://developers.google.com/protocol-buffers/ 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are 7 | // met: 8 | // 9 | // * Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // * Redistributions in binary form must reproduce the above 12 | // copyright notice, this list of conditions and the following disclaimer 13 | // in the documentation and/or other materials provided with the 14 | // distribution. 15 | // * Neither the name of Google Inc. nor the names of its 16 | // contributors may be used to endorse or promote products derived from 17 | // this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | // from google3/util/gtl/stl_util.h 32 | 33 | #ifndef GOOGLE_PROTOBUF_STUBS_STL_UTIL_H__ 34 | #define GOOGLE_PROTOBUF_STUBS_STL_UTIL_H__ 35 | 36 | #include 37 | 38 | #include 39 | namespace duckdb { 40 | namespace google { 41 | namespace protobuf { 42 | 43 | // Inside Google, this function implements a horrible, disgusting hack in which 44 | // we reach into the string's private implementation and resize it without 45 | // initializing the new bytes. In some cases doing this can significantly 46 | // improve performance. However, since it's totally non-portable it has no 47 | // place in open source code. Feel free to fill this function in with your 48 | // own disgusting hack if you want the perf boost. 49 | inline void STLStringResizeUninitialized(std::string *s, size_t new_size) { 50 | s->resize(new_size); 51 | } 52 | 53 | // As above, but we make sure to follow amortized growth in which we always 54 | // increase the capacity by at least a constant factor >1. 55 | inline void STLStringResizeUninitializedAmortized(std::string *s, size_t new_size) { 56 | const size_t cap = s->capacity(); 57 | if (new_size > cap) { 58 | // Make sure to always grow by at least a factor of 2x. 59 | s->reserve(std::max(new_size, 2 * cap)); 60 | } 61 | STLStringResizeUninitialized(s, new_size); 62 | } 63 | 64 | // Return a mutable char* pointing to a string's internal buffer, 65 | // which may not be null-terminated. Writing through this pointer will 66 | // modify the string. 67 | // 68 | // string_as_array(&str)[i] is valid for 0 <= i < str.size() until the 69 | // next call to a string method that invalidates iterators. 70 | // 71 | // As of 2006-04, there is no standard-blessed way of getting a 72 | // mutable reference to a string's internal buffer. However, issue 530 73 | // (http://www.open-std.org/JTC1/SC22/WG21/docs/lwg-active.html#530) 74 | // proposes this as the method. According to Matt Austern, this should 75 | // already work on all current implementations. 76 | inline char *string_as_array(std::string *str) { 77 | // DO NOT USE const_cast(str->data())! See the unittest for why. 78 | return str->empty() ? nullptr : &*str->begin(); 79 | } 80 | 81 | } // namespace protobuf 82 | } // namespace google 83 | } //namespace duckdb 84 | #endif // GOOGLE_PROTOBUF_STUBS_STL_UTIL_H__ 85 | -------------------------------------------------------------------------------- /third_party/google/protobuf/stubs/stringprintf.h: -------------------------------------------------------------------------------- 1 | // Protocol Buffers - Google's data interchange format 2 | // Copyright 2012 Google Inc. All rights reserved. 3 | // https://developers.google.com/protocol-buffers/ 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are 7 | // met: 8 | // 9 | // * Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // * Redistributions in binary form must reproduce the above 12 | // copyright notice, this list of conditions and the following disclaimer 13 | // in the documentation and/or other materials provided with the 14 | // distribution. 15 | // * Neither the name of Google Inc. nor the names of its 16 | // contributors may be used to endorse or promote products derived from 17 | // this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | // from google3/base/stringprintf.h 32 | // 33 | // Printf variants that place their output in a C++ string. 34 | // 35 | // Usage: 36 | // string result = StringPrintf("%d %s\n", 10, "hello"); 37 | // SStringPrintf(&result, "%d %s\n", 10, "hello"); 38 | // StringAppendF(&result, "%d %s\n", 20, "there"); 39 | 40 | #ifndef GOOGLE_PROTOBUF_STUBS_STRINGPRINTF_H 41 | #define GOOGLE_PROTOBUF_STUBS_STRINGPRINTF_H 42 | 43 | #include 44 | #include 45 | #include 46 | 47 | #include 48 | 49 | #include 50 | namespace duckdb { 51 | namespace google { 52 | namespace protobuf { 53 | 54 | // Return a C++ string 55 | extern std::string StringPrintf(const char *format, ...); 56 | 57 | // Store result into a supplied string and return it 58 | extern const std::string &SStringPrintf(std::string *dst, const char *format, ...); 59 | 60 | // Append result to a supplied string 61 | extern void StringAppendF(std::string *dst, const char *format, ...); 62 | 63 | // Lower-level routine that takes a va_list and appends to a specified 64 | // string. All other routines are just convenience wrappers around it. 65 | extern void StringAppendV(std::string *dst, const char *format, va_list ap); 66 | 67 | // The max arguments supported by StringPrintfVector 68 | extern const int kStringPrintfVectorMaxArgs; 69 | 70 | // You can use this version when all your arguments are strings, but 71 | // you don't know how many arguments you'll have at compile time. 72 | // StringPrintfVector will LOG(FATAL) if v.size() > kStringPrintfVectorMaxArgs 73 | extern std::string StringPrintfVector(const char *format, const std::vector &v); 74 | 75 | } // namespace protobuf 76 | } // namespace google 77 | } //namespace duckdb 78 | #include 79 | 80 | #endif // GOOGLE_PROTOBUF_STUBS_STRINGPRINTF_H 81 | -------------------------------------------------------------------------------- /third_party/google/protobuf/stubs/time.h: -------------------------------------------------------------------------------- 1 | // Protocol Buffers - Google's data interchange format 2 | // Copyright 2008 Google Inc. All rights reserved. 3 | // https://developers.google.com/protocol-buffers/ 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are 7 | // met: 8 | // 9 | // * Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // * Redistributions in binary form must reproduce the above 12 | // copyright notice, this list of conditions and the following disclaimer 13 | // in the documentation and/or other materials provided with the 14 | // distribution. 15 | // * Neither the name of Google Inc. nor the names of its 16 | // contributors may be used to endorse or promote products derived from 17 | // this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | #ifndef GOOGLE_PROTOBUF_STUBS_TIME_H_ 31 | #define GOOGLE_PROTOBUF_STUBS_TIME_H_ 32 | 33 | #include 34 | 35 | #include 36 | namespace duckdb { 37 | namespace google { 38 | namespace protobuf { 39 | namespace internal { 40 | 41 | struct DateTime { 42 | int year; 43 | int month; 44 | int day; 45 | int hour; 46 | int minute; 47 | int second; 48 | }; 49 | 50 | // Converts a timestamp (seconds elapsed since 1970-01-01T00:00:00, could be 51 | // negative to represent time before 1970-01-01) to DateTime. Returns false 52 | // if the timestamp is not in the range between 0001-01-01T00:00:00 and 53 | // 9999-12-31T23:59:59. 54 | bool SecondsToDateTime(int64 seconds, DateTime *time); 55 | // Converts DateTime to a timestamp (seconds since 1970-01-01T00:00:00). 56 | // Returns false if the DateTime is not valid or is not in the valid range. 57 | bool DateTimeToSeconds(const DateTime &time, int64 *seconds); 58 | 59 | void GetCurrentTime(int64 *seconds, int32 *nanos); 60 | 61 | // Formats a time string in RFC3339 format. 62 | // 63 | // For example, "2015-05-20T13:29:35.120Z". For nanos, 0, 3, 6 or 9 fractional 64 | // digits will be used depending on how many are required to represent the exact 65 | // value. 66 | // 67 | // Note that "nanos" must in the range of [0, 999999999]. 68 | std::string FormatTime(int64 seconds, int32 nanos); 69 | // Parses a time string. This method accepts RFC3339 date/time string with UTC 70 | // offset. For example, "2015-05-20T13:29:35.120-08:00". 71 | bool ParseTime(const std::string &value, int64 *seconds, int32 *nanos); 72 | 73 | } // namespace internal 74 | } // namespace protobuf 75 | } // namespace google 76 | } 77 | #include 78 | 79 | #endif // GOOGLE_PROTOBUF_STUBS_TIME_H_ 80 | -------------------------------------------------------------------------------- /third_party/google/protobuf/util/internal/constants.h: -------------------------------------------------------------------------------- 1 | // Protocol Buffers - Google's data interchange format 2 | // Copyright 2008 Google Inc. All rights reserved. 3 | // https://developers.google.com/protocol-buffers/ 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are 7 | // met: 8 | // 9 | // * Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // * Redistributions in binary form must reproduce the above 12 | // copyright notice, this list of conditions and the following disclaimer 13 | // in the documentation and/or other materials provided with the 14 | // distribution. 15 | // * Neither the name of Google Inc. nor the names of its 16 | // contributors may be used to endorse or promote products derived from 17 | // this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | #ifndef GOOGLE_PROTOBUF_UTIL_CONVERTER_CONSTANTS_H__ 32 | #define GOOGLE_PROTOBUF_UTIL_CONVERTER_CONSTANTS_H__ 33 | 34 | #include 35 | 36 | #include 37 | 38 | // This file contains constants used by //net/proto2/util/converter. 39 | namespace duckdb { 40 | namespace google { 41 | namespace protobuf { 42 | namespace util { 43 | namespace converter { 44 | // Prefix for type URLs. 45 | const char kTypeServiceBaseUrl[] = "type.googleapis.com"; 46 | 47 | // Format string for RFC3339 timestamp formatting. 48 | const char kRfc3339TimeFormat[] = "%E4Y-%m-%dT%H:%M:%S"; 49 | 50 | // Same as above, but the year value is not zero-padded i.e. this accepts 51 | // timestamps like "1-01-0001T23:59:59Z" instead of "0001-01-0001T23:59:59Z". 52 | const char kRfc3339TimeFormatNoPadding[] = "%Y-%m-%dT%H:%M:%S"; 53 | 54 | // Minimum seconds allowed in a google.protobuf.Timestamp value. 55 | const int64_t kTimestampMinSeconds = -62135596800LL; 56 | 57 | // Maximum seconds allowed in a google.protobuf.Timestamp value. 58 | const int64_t kTimestampMaxSeconds = 253402300799LL; 59 | 60 | // Minimum seconds allowed in a google.protobuf.Duration value. 61 | const int64_t kDurationMinSeconds = -315576000000LL; 62 | 63 | // Maximum seconds allowed in a google.protobuf.Duration value. 64 | const int64_t kDurationMaxSeconds = 315576000000LL; 65 | 66 | // Nano seconds in a second. 67 | const int32_t kNanosPerSecond = 1000000000; 68 | 69 | // Type url representing NULL values in google.protobuf.Struct type. 70 | const char kStructNullValueTypeUrl[] = "type.googleapis.com/google.protobuf.NullValue"; 71 | 72 | // Type string for google.protobuf.Struct 73 | const char kStructType[] = "google.protobuf.Struct"; 74 | 75 | // Type string for struct.proto's google.protobuf.Value value type. 76 | const char kStructValueType[] = "google.protobuf.Value"; 77 | 78 | // Type string for struct.proto's google.protobuf.ListValue value type. 79 | const char kStructListValueType[] = "google.protobuf.ListValue"; 80 | 81 | // Type string for google.protobuf.Timestamp 82 | const char kTimestampType[] = "google.protobuf.Timestamp"; 83 | 84 | // Type string for google.protobuf.Duration 85 | const char kDurationType[] = "google.protobuf.Duration"; 86 | 87 | // Type URL for struct value type google.protobuf.Value 88 | const char kStructValueTypeUrl[] = "type.googleapis.com/google.protobuf.Value"; 89 | 90 | // Type string for google.protobuf.Any 91 | const char kAnyType[] = "google.protobuf.Any"; 92 | 93 | // The protobuf option name of jspb.message_id; 94 | const char kOptionJspbMessageId[] = "jspb.message_id"; 95 | 96 | } // namespace converter 97 | } // namespace util 98 | } // namespace protobuf 99 | } // namespace google 100 | } 101 | #endif // GOOGLE_PROTOBUF_UTIL_CONVERTER_CONSTANTS_H__ 102 | -------------------------------------------------------------------------------- /third_party/google/protobuf/util/internal/error_listener.cc: -------------------------------------------------------------------------------- 1 | // Protocol Buffers - Google's data interchange format 2 | // Copyright 2008 Google Inc. All rights reserved. 3 | // https://developers.google.com/protocol-buffers/ 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are 7 | // met: 8 | // 9 | // * Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // * Redistributions in binary form must reproduce the above 12 | // copyright notice, this list of conditions and the following disclaimer 13 | // in the documentation and/or other materials provided with the 14 | // distribution. 15 | // * Neither the name of Google Inc. nor the names of its 16 | // contributors may be used to endorse or promote products derived from 17 | // this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | #include 32 | namespace duckdb { 33 | namespace google { 34 | namespace protobuf { 35 | namespace util { 36 | namespace converter {} // namespace converter 37 | } // namespace util 38 | } // namespace protobuf 39 | } // namespace google 40 | } -------------------------------------------------------------------------------- /third_party/google/protobuf/util/internal/error_listener.h: -------------------------------------------------------------------------------- 1 | // Protocol Buffers - Google's data interchange format 2 | // Copyright 2008 Google Inc. All rights reserved. 3 | // https://developers.google.com/protocol-buffers/ 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are 7 | // met: 8 | // 9 | // * Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // * Redistributions in binary form must reproduce the above 12 | // copyright notice, this list of conditions and the following disclaimer 13 | // in the documentation and/or other materials provided with the 14 | // distribution. 15 | // * Neither the name of Google Inc. nor the names of its 16 | // contributors may be used to endorse or promote products derived from 17 | // this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | #ifndef GOOGLE_PROTOBUF_UTIL_CONVERTER_ERROR_LISTENER_H__ 32 | #define GOOGLE_PROTOBUF_UTIL_CONVERTER_ERROR_LISTENER_H__ 33 | 34 | #include 35 | #include 36 | #include 37 | #include 38 | 39 | #include 40 | #include 41 | #include 42 | #include 43 | #include 44 | 45 | // Must be included last. 46 | #include 47 | namespace duckdb { 48 | namespace google { 49 | namespace protobuf { 50 | namespace util { 51 | namespace converter { 52 | 53 | // Interface for error listener. 54 | class ErrorListener { 55 | public: 56 | virtual ~ErrorListener() { 57 | } 58 | 59 | // Reports an invalid name at the given location. 60 | virtual void InvalidName(const LocationTrackerInterface &loc, StringPiece invalid_name, StringPiece message) = 0; 61 | 62 | // Reports an invalid value for a field. 63 | virtual void InvalidValue(const LocationTrackerInterface &loc, StringPiece type_name, StringPiece value) = 0; 64 | 65 | // Reports a missing required field. 66 | virtual void MissingField(const LocationTrackerInterface &loc, StringPiece missing_name) = 0; 67 | 68 | protected: 69 | ErrorListener() { 70 | } 71 | 72 | private: 73 | // Do not add any data members to this class. 74 | GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ErrorListener); 75 | }; 76 | 77 | // An error listener that ignores all errors. 78 | class NoopErrorListener : public ErrorListener { 79 | public: 80 | NoopErrorListener() { 81 | } 82 | ~NoopErrorListener() override { 83 | } 84 | 85 | void InvalidName(const LocationTrackerInterface & /*loc*/, StringPiece /* invalid_name */, 86 | StringPiece /* message */) override { 87 | } 88 | 89 | void InvalidValue(const LocationTrackerInterface & /*loc*/, StringPiece /* type_name */, 90 | StringPiece /* value */) override { 91 | } 92 | 93 | void MissingField(const LocationTrackerInterface & /* loc */, StringPiece /* missing_name */) override { 94 | } 95 | 96 | private: 97 | GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(NoopErrorListener); 98 | }; 99 | 100 | } // namespace converter 101 | } // namespace util 102 | } // namespace protobuf 103 | } // namespace google 104 | } 105 | #include 106 | 107 | #endif // GOOGLE_PROTOBUF_UTIL_CONVERTER_ERROR_LISTENER_H__ 108 | -------------------------------------------------------------------------------- /third_party/google/protobuf/util/internal/field_mask_utility.h: -------------------------------------------------------------------------------- 1 | // Protocol Buffers - Google's data interchange format 2 | // Copyright 2008 Google Inc. All rights reserved. 3 | // https://developers.google.com/protocol-buffers/ 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are 7 | // met: 8 | // 9 | // * Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // * Redistributions in binary form must reproduce the above 12 | // copyright notice, this list of conditions and the following disclaimer 13 | // in the documentation and/or other materials provided with the 14 | // distribution. 15 | // * Neither the name of Google Inc. nor the names of its 16 | // contributors may be used to endorse or promote products derived from 17 | // this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | // FieldMask related utility methods. 32 | 33 | #ifndef GOOGLE_PROTOBUF_UTIL_CONVERTER_FIELD_MASK_UTILITY_H__ 34 | #define GOOGLE_PROTOBUF_UTIL_CONVERTER_FIELD_MASK_UTILITY_H__ 35 | 36 | #include 37 | #include 38 | 39 | #include 40 | #include 41 | #include 42 | #include 43 | #include 44 | namespace duckdb { 45 | namespace google { 46 | namespace protobuf { 47 | namespace util { 48 | namespace converter { 49 | 50 | typedef std::function ConverterCallback; 51 | typedef std::function PathSinkCallback; 52 | 53 | // Applies a 'converter' to each segment of a FieldMask path and returns the 54 | // result. Quoted strings in the 'path' are copied to the output as-is without 55 | // converting their content. Escaping is supported within quoted strings. 56 | // For example, "ab\"_c" will be returned as "ab\"_c" without any changes. 57 | std::string ConvertFieldMaskPath(const StringPiece path, ConverterCallback converter); 58 | 59 | // Decodes a compact list of FieldMasks. For example, "a.b,a.c.d,a.c.e" will be 60 | // decoded into a list of field paths - "a.b", "a.c.d", "a.c.e". And the results 61 | // will be sent to 'path_sink', i.e. 'path_sink' will be called once per 62 | // resulting path. 63 | // Note that we also support Apiary style FieldMask form. The above example in 64 | // the Apiary style will look like "a.b,a.c(d,e)". 65 | util::Status DecodeCompactFieldMaskPaths(StringPiece paths, PathSinkCallback path_sink); 66 | 67 | } // namespace converter 68 | } // namespace util 69 | } // namespace protobuf 70 | } // namespace google 71 | } 72 | #endif // GOOGLE_PROTOBUF_UTIL_CONVERTER_FIELD_MASK_UTILITY_H__ 73 | -------------------------------------------------------------------------------- /third_party/google/protobuf/util/internal/json_escaping.h: -------------------------------------------------------------------------------- 1 | // Protocol Buffers - Google's data interchange format 2 | // Copyright 2008 Google Inc. All rights reserved. 3 | // https://developers.google.com/protocol-buffers/ 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are 7 | // met: 8 | // 9 | // * Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // * Redistributions in binary form must reproduce the above 12 | // copyright notice, this list of conditions and the following disclaimer 13 | // in the documentation and/or other materials provided with the 14 | // distribution. 15 | // * Neither the name of Google Inc. nor the names of its 16 | // contributors may be used to endorse or promote products derived from 17 | // this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | #ifndef GOOGLE_PROTOBUF_UTIL_INTERNAL__JSON_ESCAPING_H__ 32 | #define GOOGLE_PROTOBUF_UTIL_INTERNAL__JSON_ESCAPING_H__ 33 | 34 | #include 35 | 36 | #include 37 | #include 38 | namespace duckdb { 39 | namespace google { 40 | namespace protobuf { 41 | namespace util { 42 | namespace converter { 43 | 44 | class JsonEscaping { 45 | public: 46 | // The minimum value of a unicode high-surrogate code unit in the utf-16 47 | // encoding. A high-surrogate is also known as a leading-surrogate. 48 | // See http://www.unicode.org/glossary/#high_surrogate_code_unit 49 | static constexpr uint16_t kMinHighSurrogate = 0xd800; 50 | 51 | // The maximum value of a unicide high-surrogate code unit in the utf-16 52 | // encoding. A high-surrogate is also known as a leading-surrogate. 53 | // See http://www.unicode.org/glossary/#high_surrogate_code_unit 54 | static constexpr uint16_t kMaxHighSurrogate = 0xdbff; 55 | 56 | // The minimum value of a unicode low-surrogate code unit in the utf-16 57 | // encoding. A low-surrogate is also known as a trailing-surrogate. 58 | // See http://www.unicode.org/glossary/#low_surrogate_code_unit 59 | static constexpr uint16_t kMinLowSurrogate = 0xdc00; 60 | 61 | // The maximum value of a unicode low-surrogate code unit in the utf-16 62 | // encoding. A low-surrogate is also known as a trailing surrogate. 63 | // See http://www.unicode.org/glossary/#low_surrogate_code_unit 64 | static constexpr uint16_t kMaxLowSurrogate = 0xdfff; 65 | 66 | // The minimum value of a unicode supplementary code point. 67 | // See http://www.unicode.org/glossary/#supplementary_code_point 68 | static constexpr uint32_t kMinSupplementaryCodePoint = 0x010000; 69 | 70 | // The minimum value of a unicode code point. 71 | // See http://www.unicode.org/glossary/#code_point 72 | static constexpr uint32_t kMinCodePoint = 0x000000; 73 | 74 | // The maximum value of a unicode code point. 75 | // See http://www.unicode.org/glossary/#code_point 76 | static constexpr uint32_t kMaxCodePoint = 0x10ffff; 77 | 78 | JsonEscaping() { 79 | } 80 | virtual ~JsonEscaping() { 81 | } 82 | 83 | // Escape the given ByteSource to the given ByteSink. 84 | static void Escape(strings::ByteSource *input, strings::ByteSink *output); 85 | 86 | // Escape the given ByteSource to the given ByteSink. 87 | // This is optimized for the case where the string is all printable 7-bit 88 | // ASCII and does not contain a few other characters (such as quotes). 89 | static void Escape(StringPiece input, strings::ByteSink *output); 90 | 91 | private: 92 | GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(JsonEscaping); 93 | }; 94 | 95 | } // namespace converter 96 | } // namespace util 97 | } // namespace protobuf 98 | } // namespace google 99 | } 100 | #endif // GOOGLE_PROTOBUF_UTIL_INTERNAL__JSON_ESCAPING_H__ 101 | -------------------------------------------------------------------------------- /third_party/google/protobuf/util/internal/location_tracker.h: -------------------------------------------------------------------------------- 1 | // Protocol Buffers - Google's data interchange format 2 | // Copyright 2008 Google Inc. All rights reserved. 3 | // https://developers.google.com/protocol-buffers/ 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are 7 | // met: 8 | // 9 | // * Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // * Redistributions in binary form must reproduce the above 12 | // copyright notice, this list of conditions and the following disclaimer 13 | // in the documentation and/or other materials provided with the 14 | // distribution. 15 | // * Neither the name of Google Inc. nor the names of its 16 | // contributors may be used to endorse or promote products derived from 17 | // this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | #ifndef GOOGLE_PROTOBUF_UTIL_CONVERTER_LOCATION_TRACKER_H__ 32 | #define GOOGLE_PROTOBUF_UTIL_CONVERTER_LOCATION_TRACKER_H__ 33 | 34 | #include 35 | 36 | #include 37 | 38 | #include 39 | namespace duckdb { 40 | namespace google { 41 | namespace protobuf { 42 | namespace util { 43 | namespace converter { 44 | 45 | // LocationTrackerInterface is an interface for classes that track 46 | // the location information for the purpose of error reporting. 47 | class LocationTrackerInterface { 48 | public: 49 | virtual ~LocationTrackerInterface() { 50 | } 51 | 52 | // Returns the object location as human readable string. 53 | virtual std::string ToString() const = 0; 54 | 55 | protected: 56 | LocationTrackerInterface() { 57 | } 58 | 59 | private: 60 | // Please do not add any data members to this class. 61 | GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(LocationTrackerInterface); 62 | }; 63 | 64 | } // namespace converter 65 | } // namespace util 66 | } // namespace protobuf 67 | } // namespace google 68 | } 69 | #include 70 | 71 | #endif // GOOGLE_PROTOBUF_UTIL_CONVERTER_LOCATION_TRACKER_H__ 72 | -------------------------------------------------------------------------------- /third_party/google/protobuf/util/internal/object_location_tracker.h: -------------------------------------------------------------------------------- 1 | // Protocol Buffers - Google's data interchange format 2 | // Copyright 2008 Google Inc. All rights reserved. 3 | // https://developers.google.com/protocol-buffers/ 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are 7 | // met: 8 | // 9 | // * Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // * Redistributions in binary form must reproduce the above 12 | // copyright notice, this list of conditions and the following disclaimer 13 | // in the documentation and/or other materials provided with the 14 | // distribution. 15 | // * Neither the name of Google Inc. nor the names of its 16 | // contributors may be used to endorse or promote products derived from 17 | // this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | #ifndef GOOGLE_PROTOBUF_UTIL_CONVERTER_OBJECT_LOCATION_TRACKER_H__ 32 | #define GOOGLE_PROTOBUF_UTIL_CONVERTER_OBJECT_LOCATION_TRACKER_H__ 33 | 34 | #include 35 | 36 | #include 37 | #include 38 | namespace duckdb { 39 | namespace google { 40 | namespace protobuf { 41 | namespace util { 42 | namespace converter { 43 | 44 | // An empty concrete implementation of LocationTrackerInterface. 45 | class ObjectLocationTracker : public LocationTrackerInterface { 46 | public: 47 | // Creates an empty location tracker. 48 | ObjectLocationTracker() { 49 | } 50 | 51 | ~ObjectLocationTracker() override { 52 | } 53 | 54 | // Returns empty because nothing is tracked. 55 | std::string ToString() const override { 56 | return ""; 57 | } 58 | 59 | private: 60 | GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ObjectLocationTracker); 61 | }; 62 | 63 | } // namespace converter 64 | } // namespace util 65 | } // namespace protobuf 66 | } // namespace google 67 | } 68 | #endif // GOOGLE_PROTOBUF_UTIL_CONVERTER_OBJECT_LOCATION_TRACKER_H__ 69 | -------------------------------------------------------------------------------- /third_party/google/protobuf/util/internal/object_source.h: -------------------------------------------------------------------------------- 1 | // Protocol Buffers - Google's data interchange format 2 | // Copyright 2008 Google Inc. All rights reserved. 3 | // https://developers.google.com/protocol-buffers/ 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are 7 | // met: 8 | // 9 | // * Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // * Redistributions in binary form must reproduce the above 12 | // copyright notice, this list of conditions and the following disclaimer 13 | // in the documentation and/or other materials provided with the 14 | // distribution. 15 | // * Neither the name of Google Inc. nor the names of its 16 | // contributors may be used to endorse or promote products derived from 17 | // this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | #ifndef GOOGLE_PROTOBUF_UTIL_CONVERTER_OBJECT_SOURCE_H__ 32 | #define GOOGLE_PROTOBUF_UTIL_CONVERTER_OBJECT_SOURCE_H__ 33 | 34 | #include 35 | #include 36 | #include 37 | #include 38 | 39 | // Must be included last. 40 | #include 41 | namespace duckdb { 42 | namespace google { 43 | namespace protobuf { 44 | namespace util { 45 | namespace converter { 46 | 47 | class ObjectWriter; 48 | 49 | // An ObjectSource is anything that can write to an ObjectWriter. 50 | // Implementation of this interface typically provide constructors or 51 | // factory methods to create an instance based on some source data, for 52 | // example, a character stream, or protobuf. 53 | // 54 | // Derived classes could be thread-unsafe. 55 | class ObjectSource { 56 | public: 57 | virtual ~ObjectSource() { 58 | } 59 | 60 | // Writes to the ObjectWriter 61 | virtual util::Status WriteTo(ObjectWriter *ow) const { 62 | return NamedWriteTo("", ow); 63 | } 64 | 65 | // Writes to the ObjectWriter with a custom name for the message. 66 | // This is useful when you chain ObjectSource together by embedding one 67 | // within another. 68 | virtual util::Status NamedWriteTo(StringPiece name, ObjectWriter *ow) const = 0; 69 | 70 | protected: 71 | ObjectSource() { 72 | } 73 | 74 | private: 75 | // Do not add any data members to this class. 76 | GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ObjectSource); 77 | }; 78 | 79 | } // namespace converter 80 | } // namespace util 81 | } // namespace protobuf 82 | } // namespace google 83 | } 84 | #include 85 | 86 | #endif // GOOGLE_PROTOBUF_UTIL_CONVERTER_OBJECT_SOURCE_H__ 87 | -------------------------------------------------------------------------------- /third_party/google/protobuf/util/internal/object_writer.cc: -------------------------------------------------------------------------------- 1 | // Protocol Buffers - Google's data interchange format 2 | // Copyright 2008 Google Inc. All rights reserved. 3 | // https://developers.google.com/protocol-buffers/ 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are 7 | // met: 8 | // 9 | // * Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // * Redistributions in binary form must reproduce the above 12 | // copyright notice, this list of conditions and the following disclaimer 13 | // in the documentation and/or other materials provided with the 14 | // distribution. 15 | // * Neither the name of Google Inc. nor the names of its 16 | // contributors may be used to endorse or promote products derived from 17 | // this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | #include 32 | 33 | #include 34 | namespace duckdb { 35 | namespace google { 36 | namespace protobuf { 37 | namespace util { 38 | namespace converter { 39 | 40 | // static 41 | void ObjectWriter::RenderDataPieceTo(const DataPiece &data, StringPiece name, ObjectWriter *ow) { 42 | switch (data.type()) { 43 | case DataPiece::TYPE_INT32: { 44 | ow->RenderInt32(name, data.ToInt32().value()); 45 | break; 46 | } 47 | case DataPiece::TYPE_INT64: { 48 | ow->RenderInt64(name, data.ToInt64().value()); 49 | break; 50 | } 51 | case DataPiece::TYPE_UINT32: { 52 | ow->RenderUint32(name, data.ToUint32().value()); 53 | break; 54 | } 55 | case DataPiece::TYPE_UINT64: { 56 | ow->RenderUint64(name, data.ToUint64().value()); 57 | break; 58 | } 59 | case DataPiece::TYPE_DOUBLE: { 60 | ow->RenderDouble(name, data.ToDouble().value()); 61 | break; 62 | } 63 | case DataPiece::TYPE_FLOAT: { 64 | ow->RenderFloat(name, data.ToFloat().value()); 65 | break; 66 | } 67 | case DataPiece::TYPE_BOOL: { 68 | ow->RenderBool(name, data.ToBool().value()); 69 | break; 70 | } 71 | case DataPiece::TYPE_STRING: { 72 | ow->RenderString(name, data.ToString().value()); 73 | break; 74 | } 75 | case DataPiece::TYPE_BYTES: { 76 | ow->RenderBytes(name, data.ToBytes().value()); 77 | break; 78 | } 79 | case DataPiece::TYPE_NULL: { 80 | ow->RenderNull(name); 81 | break; 82 | } 83 | default: 84 | break; 85 | } 86 | } 87 | 88 | } // namespace converter 89 | } // namespace util 90 | } // namespace protobuf 91 | } // namespace google 92 | } -------------------------------------------------------------------------------- /third_party/google/protobuf/util/internal/type_info.h: -------------------------------------------------------------------------------- 1 | // Protocol Buffers - Google's data interchange format 2 | // Copyright 2008 Google Inc. All rights reserved. 3 | // https://developers.google.com/protocol-buffers/ 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are 7 | // met: 8 | // 9 | // * Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // * Redistributions in binary form must reproduce the above 12 | // copyright notice, this list of conditions and the following disclaimer 13 | // in the documentation and/or other materials provided with the 14 | // distribution. 15 | // * Neither the name of Google Inc. nor the names of its 16 | // contributors may be used to endorse or promote products derived from 17 | // this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | #ifndef GOOGLE_PROTOBUF_UTIL_CONVERTER_TYPE_INFO_H__ 32 | #define GOOGLE_PROTOBUF_UTIL_CONVERTER_TYPE_INFO_H__ 33 | 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | 41 | // Must be included last. 42 | #include 43 | namespace duckdb { 44 | namespace google { 45 | namespace protobuf { 46 | namespace util { 47 | namespace converter { 48 | // Internal helper class for type resolving. Note that this class is not 49 | // thread-safe and should only be accessed in one thread. 50 | class TypeInfo { 51 | public: 52 | TypeInfo() { 53 | } 54 | virtual ~TypeInfo() { 55 | } 56 | 57 | // Resolves a type url into a Type. If the type url is invalid, returns 58 | // INVALID_ARGUMENT error status. If the type url is valid but the 59 | // corresponding type cannot be found, returns a NOT_FOUND error status. 60 | // 61 | // This TypeInfo class retains the ownership of the returned pointer. 62 | virtual util::StatusOr ResolveTypeUrl(StringPiece type_url) const = 0; 63 | 64 | // Resolves a type url into a Type. Like ResolveTypeUrl() but returns 65 | // NULL if the type url is invalid or the type cannot be found. 66 | // 67 | // This TypeInfo class retains the ownership of the returned pointer. 68 | virtual const google::protobuf::Type *GetTypeByTypeUrl(StringPiece type_url) const = 0; 69 | 70 | // Resolves a type url for an enum. Returns NULL if the type url is 71 | // invalid or the type cannot be found. 72 | // 73 | // This TypeInfo class retains the ownership of the returned pointer. 74 | virtual const google::protobuf::Enum *GetEnumByTypeUrl(StringPiece type_url) const = 0; 75 | 76 | // Looks up a field in the specified type given a CamelCase name. 77 | virtual const google::protobuf::Field *FindField(const google::protobuf::Type *type, 78 | StringPiece camel_case_name) const = 0; 79 | 80 | // Creates a TypeInfo object that looks up type information from a 81 | // TypeResolver. Caller takes ownership of the returned pointer. 82 | static TypeInfo *NewTypeInfo(TypeResolver *type_resolver); 83 | 84 | private: 85 | GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(TypeInfo); 86 | }; 87 | 88 | } // namespace converter 89 | } // namespace util 90 | } // namespace protobuf 91 | } // namespace google 92 | } 93 | #include 94 | 95 | #endif // GOOGLE_PROTOBUF_UTIL_CONVERTER_TYPE_INFO_H__ 96 | -------------------------------------------------------------------------------- /third_party/google/protobuf/util/type_resolver.h: -------------------------------------------------------------------------------- 1 | // Protocol Buffers - Google's data interchange format 2 | // Copyright 2008 Google Inc. All rights reserved. 3 | // https://developers.google.com/protocol-buffers/ 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are 7 | // met: 8 | // 9 | // * Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // * Redistributions in binary form must reproduce the above 12 | // copyright notice, this list of conditions and the following disclaimer 13 | // in the documentation and/or other materials provided with the 14 | // distribution. 15 | // * Neither the name of Google Inc. nor the names of its 16 | // contributors may be used to endorse or promote products derived from 17 | // this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | // Defines a TypeResolver for the Any message. 32 | 33 | #ifndef GOOGLE_PROTOBUF_UTIL_TYPE_RESOLVER_H__ 34 | #define GOOGLE_PROTOBUF_UTIL_TYPE_RESOLVER_H__ 35 | 36 | #include 37 | 38 | #include 39 | #include 40 | #include 41 | #include 42 | 43 | #include 44 | namespace duckdb{ 45 | namespace google { 46 | namespace protobuf { 47 | class DescriptorPool; 48 | namespace util { 49 | 50 | // Abstract interface for a type resolver. 51 | // 52 | // Implementations of this interface must be thread-safe. 53 | class TypeResolver { 54 | public: 55 | TypeResolver() {} 56 | virtual ~TypeResolver() {} 57 | 58 | // Resolves a type url for a message type. 59 | virtual util::Status ResolveMessageType( 60 | const std::string& type_url, google::protobuf::Type* message_type) = 0; 61 | 62 | // Resolves a type url for an enum type. 63 | virtual util::Status ResolveEnumType(const std::string& type_url, 64 | google::protobuf::Enum* enum_type) = 0; 65 | 66 | private: 67 | GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(TypeResolver); 68 | }; 69 | 70 | } // namespace util 71 | } // namespace protobuf 72 | } // namespace google 73 | } 74 | #include 75 | 76 | #endif // GOOGLE_PROTOBUF_UTIL_TYPE_RESOLVER_H__ 77 | -------------------------------------------------------------------------------- /third_party/google/protobuf/util/type_resolver_util.h: -------------------------------------------------------------------------------- 1 | // Protocol Buffers - Google's data interchange format 2 | // Copyright 2008 Google Inc. All rights reserved. 3 | // https://developers.google.com/protocol-buffers/ 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are 7 | // met: 8 | // 9 | // * Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // * Redistributions in binary form must reproduce the above 12 | // copyright notice, this list of conditions and the following disclaimer 13 | // in the documentation and/or other materials provided with the 14 | // distribution. 15 | // * Neither the name of Google Inc. nor the names of its 16 | // contributors may be used to endorse or promote products derived from 17 | // this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | // Defines utilities for the TypeResolver. 32 | 33 | #ifndef GOOGLE_PROTOBUF_UTIL_TYPE_RESOLVER_UTIL_H__ 34 | #define GOOGLE_PROTOBUF_UTIL_TYPE_RESOLVER_UTIL_H__ 35 | 36 | #include 37 | namespace duckdb { 38 | namespace google { 39 | namespace protobuf { 40 | class DescriptorPool; 41 | namespace util { 42 | class TypeResolver; 43 | 44 | #include 45 | 46 | // Creates a TypeResolver that serves type information in the given descriptor 47 | // pool. Caller takes ownership of the returned TypeResolver. 48 | TypeResolver *NewTypeResolverForDescriptorPool(const std::string &url_prefix, const DescriptorPool *pool); 49 | 50 | } // namespace util 51 | } // namespace protobuf 52 | } // namespace google 53 | } 54 | #include 55 | 56 | #endif // GOOGLE_PROTOBUF_UTIL_TYPE_RESOLVER_UTIL_H__ 57 | -------------------------------------------------------------------------------- /vcpkg.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": [ 3 | ] 4 | } 5 | --------------------------------------------------------------------------------