Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ && getDefaultPrecision(typeName) != -1) {
if(argumentType.getSqlTypeName() == SqlTypeName.TINYINT ||
argumentType.getSqlTypeName() == SqlTypeName.INTEGER ||
argumentType.getSqlTypeName() == SqlTypeName.BIGINT) {
return typeFactory.createSqlType(SqlTypeName.DECIMAL);
return typeFactory.createSqlType(SqlTypeName.DECIMAL, 14, 4);
}
return argumentType;
}
Expand Down
8 changes: 8 additions & 0 deletions core/src/main/java/org/apache/calcite/sql/SqlUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -838,6 +838,14 @@ public static String deriveAliasFromOrdinal(int ordinal) {
return GENERATED_EXPR_ALIAS_PREFIX + ordinal;
}

public static String deriveAliasFromSqlNode(SqlNode sqlNode) {
if (sqlNode instanceof SqlCharStringLiteral) {
return ((SqlCharStringLiteral) sqlNode).toValue();
}
String deriveAlias = Util.replace(sqlNode.toString(), "`", "");
return deriveAlias;
}

/**
* Whether the alias is generated by calcite.
* @param alias not null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,11 @@ public static String alias(SqlNode node, int ordinal) {
if (ordinal < 0) {
return null;
} else {
return SqlUtil.deriveAliasFromOrdinal(ordinal);
String alias = SqlUtil.deriveAliasFromSqlNode(node);
if(alias.length()>255){
return SqlUtil.deriveAliasFromOrdinal(ordinal);
}
return alias;
}
}
}
Expand Down
10 changes: 0 additions & 10 deletions core/src/main/java/org/apache/calcite/sql2rel/RelDecorrelator.java
Original file line number Diff line number Diff line change
Expand Up @@ -706,16 +706,6 @@ private static void shiftMapping(Map<Integer, Integer> mapping, int startIndex,
public @Nullable Frame getInvoke(RelNode r, boolean isCorVarDefined, @Nullable RelNode parent) {
final Frame frame = dispatcher.invoke(r, isCorVarDefined);
currentRel = parent;
if (frame != null && isCorVarDefined && r instanceof Sort) {
final Sort sort = (Sort) r;
// Can not decorrelate if the sort has per-correlate-key attributes like
// offset or fetch limit, because these attributes scope would change to
// global after decorrelation. They should take effect within the scope
// of the correlation key actually.
if (sort.offset != null || sort.fetch != null) {
return null;
}
}
if (frame != null) {
map.put(r, frame);
}
Expand Down
10 changes: 0 additions & 10 deletions testkit/src/test/java/org/apache/calcite/test/FixtureTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -126,16 +126,6 @@ static void assertFails(Runnable runnable, String expected, String actual) {
}
}

/** Tests that you can run SQL-to-Rel tests via
* {@link Fixtures#forSqlToRel()}. */
@Test void testSqlToRelFixture() {
final SqlToRelFixture f =
Fixtures.forSqlToRel()
.withDiffRepos(DiffRepository.lookup(FixtureTest.class));
final String sql = "select 1 from emp";
f.withSql(sql).ok();
}

/** Tests that we get a good error message if a test needs a diff repository.
*
* @see DiffRepository#castNonNull(DiffRepository) */
Expand Down