Re: [PR] [CALCITE-6052] SqlImplementor writes FLOATING POINT literals as DECIMAL literals [calcite]
sonarcloud[bot] commented on PR #3472: URL: https://github.com/apache/calcite/pull/3472#issuecomment-1765324255 Kudos, SonarCloud Quality Gate passed! [![Quality Gate passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/passed-16px.png 'Quality Gate passed')](https://sonarcloud.io/dashboard?id=apache_calcite=3472) [![Bug](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug-16px.png 'Bug')](https://sonarcloud.io/project/issues?id=apache_calcite=3472=false=BUG) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache_calcite=3472=false=BUG) [0 Bugs](https://sonarcloud.io/project/issues?id=apache_calcite=3472=false=BUG) [![Vulnerability](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/vulnerability-16px.png 'Vulnerability')](https://sonarcloud.io/project/issues?id=apache_calcite=3472=false=VULNERABILITY) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache_calcite=3472=false=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=apache_calcite=3472=false=VULNERABILITY) [![Security Hotspot](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/security_hotspot-16px.png 'Security Hotspot')](https://sonarcloud.io/project/security_hotspots?id=apache_calcite=3472=false=SECURITY_HOTSPOT) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/security_hotspots?id=apache_calcite=3472=false=SECURITY_HOTSPOT) [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_calcite=3472=false=SECURITY_HOTSPOT) [![Code Smell](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/code_smell-16px.png 'Code Smell')](https://sonarcloud.io/project/issues?id=apache_calcite=3472=false=CODE_SMELL) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache_calcite=3472=false=CODE_SMELL) [2 Code Smells](https://sonarcloud.io/project/issues?id=apache_calcite=3472=false=CODE_SMELL) [![83.3%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/60-16px.png '83.3%')](https://sonarcloud.io/component_measures?id=apache_calcite=3472=new_coverage=list) [83.3% Coverage](https://sonarcloud.io/component_measures?id=apache_calcite=3472=new_coverage=list) [![0.0%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/Duplications/3-16px.png '0.0%')](https://sonarcloud.io/component_measures?id=apache_calcite=3472=new_duplicated_lines_density=list) [0.0% Duplication](https://sonarcloud.io/component_measures?id=apache_calcite=3472=new_duplicated_lines_density=list) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@calcite.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org
Re: [PR] [CALCITE-5986] The typeFamily property of SqlTypeName is used inconsistently [calcite]
sonarcloud[bot] commented on PR #3411: URL: https://github.com/apache/calcite/pull/3411#issuecomment-1765292305 Kudos, SonarCloud Quality Gate passed! [![Quality Gate passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/passed-16px.png 'Quality Gate passed')](https://sonarcloud.io/dashboard?id=apache_calcite=3411) [![Bug](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug-16px.png 'Bug')](https://sonarcloud.io/project/issues?id=apache_calcite=3411=false=BUG) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache_calcite=3411=false=BUG) [0 Bugs](https://sonarcloud.io/project/issues?id=apache_calcite=3411=false=BUG) [![Vulnerability](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/vulnerability-16px.png 'Vulnerability')](https://sonarcloud.io/project/issues?id=apache_calcite=3411=false=VULNERABILITY) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache_calcite=3411=false=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=apache_calcite=3411=false=VULNERABILITY) [![Security Hotspot](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/security_hotspot-16px.png 'Security Hotspot')](https://sonarcloud.io/project/security_hotspots?id=apache_calcite=3411=false=SECURITY_HOTSPOT) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/security_hotspots?id=apache_calcite=3411=false=SECURITY_HOTSPOT) [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_calcite=3411=false=SECURITY_HOTSPOT) [![Code Smell](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/code_smell-16px.png 'Code Smell')](https://sonarcloud.io/project/issues?id=apache_calcite=3411=false=CODE_SMELL) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache_calcite=3411=false=CODE_SMELL) [11 Code Smells](https://sonarcloud.io/project/issues?id=apache_calcite=3411=false=CODE_SMELL) [![77.9%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/60-16px.png '77.9%')](https://sonarcloud.io/component_measures?id=apache_calcite=3411=new_coverage=list) [77.9% Coverage](https://sonarcloud.io/component_measures?id=apache_calcite=3411=new_coverage=list) [![0.0%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/Duplications/3-16px.png '0.0%')](https://sonarcloud.io/component_measures?id=apache_calcite=3411=new_duplicated_lines_density=list) [0.0% Duplication](https://sonarcloud.io/component_measures?id=apache_calcite=3411=new_duplicated_lines_density=list) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@calcite.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org
Re: [PR] [CALCITE-5986] The typeFamily property of SqlTypeName is used inconsistently [calcite]
mihaibudiu commented on PR #3411: URL: https://github.com/apache/calcite/pull/3411#issuecomment-1765287239 I realize that this is a more intrusive change, but I think it does make a small step in improving the use to type families. This PR also fixes a bug introduced by the incorrect use of type families. I will have submitted #3472 with just that fix, it illustrates why the type families are wrong. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@calcite.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[PR] [CALCITE-6052] reltosql writes FLOATING POINT literals as DECIMAL literals [calcite]
mihaibudiu opened a new pull request, #3472: URL: https://github.com/apache/calcite/pull/3472 This bug was also fixed in #3411, but perhaps we can merge this PR more easily since it is much smaller. I didn't add a new test case since the pig test case covers it. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@calcite.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org
Re: [PR] [CALCITE-6030] DATE_PART is not handled by the RexToLixTranslator [calcite]
sonarcloud[bot] commented on PR #3446: URL: https://github.com/apache/calcite/pull/3446#issuecomment-1765276947 Kudos, SonarCloud Quality Gate passed! [![Quality Gate passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/passed-16px.png 'Quality Gate passed')](https://sonarcloud.io/dashboard?id=apache_calcite=3446) [![Bug](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug-16px.png 'Bug')](https://sonarcloud.io/project/issues?id=apache_calcite=3446=false=BUG) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache_calcite=3446=false=BUG) [0 Bugs](https://sonarcloud.io/project/issues?id=apache_calcite=3446=false=BUG) [![Vulnerability](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/vulnerability-16px.png 'Vulnerability')](https://sonarcloud.io/project/issues?id=apache_calcite=3446=false=VULNERABILITY) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache_calcite=3446=false=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=apache_calcite=3446=false=VULNERABILITY) [![Security Hotspot](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/security_hotspot-16px.png 'Security Hotspot')](https://sonarcloud.io/project/security_hotspots?id=apache_calcite=3446=false=SECURITY_HOTSPOT) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/security_hotspots?id=apache_calcite=3446=false=SECURITY_HOTSPOT) [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_calcite=3446=false=SECURITY_HOTSPOT) [![Code Smell](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/code_smell-16px.png 'Code Smell')](https://sonarcloud.io/project/issues?id=apache_calcite=3446=false=CODE_SMELL) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache_calcite=3446=false=CODE_SMELL) [2 Code Smells](https://sonarcloud.io/project/issues?id=apache_calcite=3446=false=CODE_SMELL) [![100.0%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/100-16px.png '100.0%')](https://sonarcloud.io/component_measures?id=apache_calcite=3446=new_coverage=list) [100.0% Coverage](https://sonarcloud.io/component_measures?id=apache_calcite=3446=new_coverage=list) [![0.0%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/Duplications/3-16px.png '0.0%')](https://sonarcloud.io/component_measures?id=apache_calcite=3446=new_duplicated_lines_density=list) [0.0% Duplication](https://sonarcloud.io/component_measures?id=apache_calcite=3446=new_duplicated_lines_density=list) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@calcite.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org
Re: [PR] [CALCITE-6030] DATE_PART is not handled by the RexToLixTranslator [calcite]
mihaibudiu commented on PR #3446: URL: https://github.com/apache/calcite/pull/3446#issuecomment-1765244142 I have reworked this bugfix so that it can be merged right away, and we can debate #3445 separately. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@calcite.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org
Re: [PR] [CALCITE-5884] Type Inference rule for ARRAY_TO_STRING is incorrect [calcite]
sonarcloud[bot] commented on PR #3346: URL: https://github.com/apache/calcite/pull/3346#issuecomment-1765235356 Kudos, SonarCloud Quality Gate passed! [![Quality Gate passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/passed-16px.png 'Quality Gate passed')](https://sonarcloud.io/dashboard?id=apache_calcite=3346) [![Bug](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug-16px.png 'Bug')](https://sonarcloud.io/project/issues?id=apache_calcite=3346=false=BUG) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache_calcite=3346=false=BUG) [0 Bugs](https://sonarcloud.io/project/issues?id=apache_calcite=3346=false=BUG) [![Vulnerability](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/vulnerability-16px.png 'Vulnerability')](https://sonarcloud.io/project/issues?id=apache_calcite=3346=false=VULNERABILITY) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache_calcite=3346=false=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=apache_calcite=3346=false=VULNERABILITY) [![Security Hotspot](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/security_hotspot-16px.png 'Security Hotspot')](https://sonarcloud.io/project/security_hotspots?id=apache_calcite=3346=false=SECURITY_HOTSPOT) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/security_hotspots?id=apache_calcite=3346=false=SECURITY_HOTSPOT) [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_calcite=3346=false=SECURITY_HOTSPOT) [![Code Smell](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/code_smell-16px.png 'Code Smell')](https://sonarcloud.io/project/issues?id=apache_calcite=3346=false=CODE_SMELL) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache_calcite=3346=false=CODE_SMELL) [0 Code Smells](https://sonarcloud.io/project/issues?id=apache_calcite=3346=false=CODE_SMELL) [![100.0%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/100-16px.png '100.0%')](https://sonarcloud.io/component_measures?id=apache_calcite=3346=new_coverage=list) [100.0% Coverage](https://sonarcloud.io/component_measures?id=apache_calcite=3346=new_coverage=list) [![0.0%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/Duplications/3-16px.png '0.0%')](https://sonarcloud.io/component_measures?id=apache_calcite=3346=new_duplicated_lines_density=list) [0.0% Duplication](https://sonarcloud.io/component_measures?id=apache_calcite=3346=new_duplicated_lines_density=list) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@calcite.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org
Re: [PR] [CALCITE-5979] Add REGEXP_REPLACE function (enabled in BigQuery library) [calcite]
Anthrino commented on code in PR #3460: URL: https://github.com/apache/calcite/pull/3460#discussion_r1361239481 ## core/src/main/java/org/apache/calcite/sql/validate/SqlConformanceEnum.java: ## @@ -240,6 +240,15 @@ public enum SqlConformanceEnum implements SqlConformance { } } + @Override public boolean isRegexReplaceCaptureGroupDollarIndexed() { Review Comment: Hi @julianhyde, just a gentle reminder on this. We wanted to get your feedback on this approach of checking BQ conformance against introducing a separate operator, would be great if you can have a look, thanks! -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@calcite.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org
Re: [PR] [CALCITE-5884] Type Inference rule for ARRAY_TO_STRING is incorrect [calcite]
mihaibudiu commented on PR #3346: URL: https://github.com/apache/calcite/pull/3346#issuecomment-1765213995 > @mihaibudiu ,please rebase the latest main branch's code. Done -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@calcite.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org
Re: [PR] [CALCITE-5918] Add MAP function (enabled in Spark library) [calcite]
chucheng92 commented on code in PR #3459: URL: https://github.com/apache/calcite/pull/3459#discussion_r1358158316 ## core/src/main/java/org/apache/calcite/sql/type/OperandTypes.java: ## @@ -1221,6 +1225,53 @@ private static class MapFromEntriesOperandTypeChecker } } + /** + * Operand type-checking strategy for a MAP function, it allows empty map. + */ + private static class MapFunctionOperandTypeChecker + extends SameOperandTypeChecker { + +MapFunctionOperandTypeChecker() { + super(-1); +} + +@Override public boolean checkOperandTypes(final SqlCallBinding callBinding, +final boolean throwOnFailure) { + final List argTypes = + SqlTypeUtil.deriveType(callBinding, callBinding.operands()); + // allows empty map + if (argTypes.size() == 0) { +return true; + } + // the size of map arg types must be even. + if (argTypes.size() % 2 > 0) { +throw callBinding.newValidationError(RESOURCE.mapRequiresEvenArgCount()); + } + final Pair<@Nullable RelDataType, @Nullable RelDataType> componentType = + getComponentTypes( + callBinding.getTypeFactory(), argTypes); + // check key type & value type + if (null == componentType.left || null == componentType.right) { +if (throwOnFailure) { + throw callBinding.newValidationError(RESOURCE.needSameTypeParameter()); +} +return false; + } + return true; +} + +/** + * Extract the key type and value type of arg types. + */ +private static Pair<@Nullable RelDataType, @Nullable RelDataType> getComponentTypes( +RelDataTypeFactory typeFactory, +List argTypes) { + return Pair.of( + typeFactory.leastRestrictive(Util.quotientList(argTypes, 2, 0)), Review Comment: Util.quotientList(argTypes, 2, 0): This extracts all elements at even indices from argTypes. It represents the types of keys in the map as they are placed at even positions e.g. 0, 2, 4, etc. details please see Util.quotientList. std MapValueConstructor has same logic. see: https://github.com/apache/calcite/blob/5151168e9a9035595939c2ae0f21a06984229209/core/src/main/java/org/apache/calcite/sql/fun/SqlMapValueConstructor.java#L90 I've added some comments here for better readability. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@calcite.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[calcite] branch main updated: [CALCITE-6014] Create a SqlOperatorFixture that parses, unparses, and then parses again before executing
This is an automated email from the ASF dual-hosted git repository. rubenql pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/calcite.git The following commit(s) were added to refs/heads/main by this push: new 5151168e9a [CALCITE-6014] Create a SqlOperatorFixture that parses, unparses, and then parses again before executing 5151168e9a is described below commit 5151168e9a9035595939c2ae0f21a06984229209 Author: Mihai Budiu AuthorDate: Fri Oct 13 11:42:07 2023 -0700 [CALCITE-6014] Create a SqlOperatorFixture that parses, unparses, and then parses again before executing Signed-off-by: Mihai Budiu --- .../calcite/test/SqlOperatorUnparseTest.java | 116 + .../calcite/test/SqlOperatorFixtureImpl.java | 2 +- 2 files changed, 117 insertions(+), 1 deletion(-) diff --git a/core/src/test/java/org/apache/calcite/test/SqlOperatorUnparseTest.java b/core/src/test/java/org/apache/calcite/test/SqlOperatorUnparseTest.java new file mode 100644 index 00..13512d1aa4 --- /dev/null +++ b/core/src/test/java/org/apache/calcite/test/SqlOperatorUnparseTest.java @@ -0,0 +1,116 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to you under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.calcite.test; + +import org.apache.calcite.sql.SqlNode; +import org.apache.calcite.sql.parser.SqlParseException; +import org.apache.calcite.sql.parser.SqlParser; +import org.apache.calcite.sql.test.SqlOperatorFixture; +import org.apache.calcite.sql.test.SqlTestFactory; + +import org.junit.jupiter.api.Disabled; + +import java.util.function.Consumer; +import java.util.function.UnaryOperator; + +/** + * Version of a SqlOperatorTest which first parses and unparses + * the test program before executing it. Although similar to + * {@link org.apache.calcite.sql.parser.SqlUnParserTest}, + * this test also validates the code after unparsing. + */ +@SuppressWarnings("JavadocReference") +public class SqlOperatorUnparseTest extends CalciteSqlOperatorTest { + /** Fixture that runs an operator test after parsing and unparsing a query. */ + static class SqlOperatorFixtureUnparseImpl extends SqlOperatorFixtureImpl { +SqlOperatorFixtureUnparseImpl(SqlTestFactory factory) { + super(factory, new UnparseTester(factory), false); +} + +/** + * Retrieve the tester as an UnparseTester. A downcast is needed because + * our tester implements a richer API than a regular SqlTester -- for example, + * it has a method withFactory. + */ +UnparseTester getUnparseTester() { + return (UnparseTester) this.getTester(); +} + +public static final SqlOperatorFixtureImpl DEFAULT = +new SqlOperatorFixtureUnparseImpl(SqlTestFactory.INSTANCE); + +@Override public SqlOperatorFixture withFactory(UnaryOperator transform) { + return super + .withFactory(transform) + // Pass the transform to the tester + .withTester(t -> this.getUnparseTester().withFactory(transform)); +} + } + + @Override protected SqlOperatorFixture fixture() { +return SqlOperatorFixtureUnparseImpl.DEFAULT; + } + + /** A tester which parses, unparses, and then tests a query. */ + static class UnparseTester extends TesterImpl { +public final SqlTestFactory factory; + +UnparseTester(SqlTestFactory factory) { + this.factory = factory; +} + +TesterImpl withFactory(UnaryOperator transform) { + return new UnparseTester(transform.apply(this.factory)); +} + +String rewrite(String sql) throws SqlParseException { + final SqlParser parser = factory.createParser(sql); + final SqlNode sqlNode = parser.parseStmt(); + return sqlNode.toSqlString(c -> c).getSql(); +} + +@Override public void forEachQuery( +SqlTestFactory factory, String expression, Consumer consumer) { + consumer.accept(buildQuery2(factory, expression)); +} + +@Override public void check(SqlTestFactory factory, String sql, TypeChecker typeChecker, +ParameterChecker parameterChecker, ResultChecker resultChecker) { + try { +String optQuery = this.rewrite(sql); +super.check(factory, optQuery, typeChecker, parameterChecker, resultChecker); + }
Re: [PR] [CALCITE-6014] Create a SqlOperatorFixture that parses, unparses, and… [calcite]
rubenada merged PR #3433: URL: https://github.com/apache/calcite/pull/3433 -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@calcite.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org