Polishing.

Inherit column name when using function builder.

See #1504
This commit is contained in:
Mark Paluch
2025-02-13 14:13:21 +01:00
parent c61f305350
commit 76a29503e6
2 changed files with 7 additions and 5 deletions

View File

@@ -134,7 +134,7 @@ public class Columns implements Iterable<ColumnName> {
* @return a new {@link Columns} object containing all column definitions and the TTL for {@code columnName}.
*/
public Columns ttl(String columnName) {
return select(columnName, SelectorBuilder::ttl);
return select(columnName, FunctionCall.from("TTL", ColumnSelector.from(columnName)));
}
/**
@@ -145,7 +145,7 @@ public class Columns implements Iterable<ColumnName> {
* @return a new {@link Columns} object containing all column definitions and the TTL for {@code columnName}.
*/
public Columns ttl(CqlIdentifier columnName) {
return select(columnName, SelectorBuilder::ttl);
return select(columnName, FunctionCall.from("TTL", ColumnSelector.from(columnName)));
}
/**
@@ -161,7 +161,8 @@ public class Columns implements Iterable<ColumnName> {
/**
* Include column {@code columnName} with a built {@link Selector}. This column selection overrides an existing
* selection for the column name.
* selection for the column name. {@link SelectorBuilder} uses the given {@code columnName} as column alias to
* represent the selection in the result.
*
* @param columnName must not be {@literal null}.
* @return a new {@link Columns} object containing all column definitions and the selected {@code columnName}.
@@ -175,7 +176,8 @@ public class Columns implements Iterable<ColumnName> {
/**
* Include column {@code columnName} with a built {@link Selector}. This column selection overrides an existing
* selection for the column name.
* selection for the column name. {@link SelectorBuilder} uses the given {@code columnName} as column alias to
* represent the selection in the result.
*
* @param columnName must not be {@literal null}.
* @return a new {@link Columns} object containing all column definitions and the selected {@code columnName}.

View File

@@ -960,7 +960,7 @@ class StatementFactoryUnitTests {
.build(ParameterHandling.BY_NAME);
assertThat(statement.getQuery()).isEqualTo(
"SELECT comment,similarity_cosine(vector,[0.2, 0.15, 0.3, 0.2, 0.05]) FROM withvector ORDER BY vector ANN OF [1.2, 1.3]");
"SELECT comment,similarity_cosine(vector,[0.2, 0.15, 0.3, 0.2, 0.05]) AS vector FROM withvector ORDER BY vector ANN OF [1.2, 1.3]");
assertThat(statement.getNamedValues()).isEmpty();
}