Skip to content

Commit

Permalink
fix issue
Browse files Browse the repository at this point in the history
  • Loading branch information
Samrat002 committed Aug 10, 2024
1 parent 2cfa1bf commit f2d5178
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -382,18 +382,38 @@ public static String getGlueFunctionClassName(CatalogFunction function) {
* @param sb StringBuilder.
* @return Derived String from {@link Expression}.
*/
// public static String getExpressionString(Expression expression, StringBuilder sb) {
//
// for (Expression childExpression : expression.getChildren()) {
// if (childExpression.getChildren() != null && !childExpression.getChildren().isEmpty()) {
// getExpressionString(childExpression, sb);
// }
// }
// return sb.insert(
// 0,
// expression.asSummaryString()
// + GlueCatalogConstants.SPACE
// + GlueCatalogConstants.AND)
// .toString();
// }
public static String getExpressionString(Expression expression, StringBuilder sb) {

for (Expression childExpression : expression.getChildren()) {
if (childExpression.getChildren() != null && !childExpression.getChildren().isEmpty()) {
getExpressionString(childExpression, sb);
}
}
return sb.insert(
0,
expression.asSummaryString()
+ GlueCatalogConstants.SPACE
+ GlueCatalogConstants.AND)
.toString();

// If the StringBuilder is not empty, append "AND "
if (sb.length() > 0) {
sb.append(GlueCatalogConstants.SPACE)
.append(GlueCatalogConstants.AND)
.append(GlueCatalogConstants.SPACE);
}

// Append the current expression summary
sb.append(expression.asSummaryString());

return sb.toString();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,16 @@

package org.apache.flink.table.catalog.glue.util;

import org.apache.flink.table.api.DataTypes;
import org.apache.flink.table.catalog.CatalogDatabase;
import org.apache.flink.table.catalog.CatalogFunctionImpl;
import org.apache.flink.table.catalog.FunctionLanguage;
import org.apache.flink.table.catalog.ObjectPath;
import org.apache.flink.table.catalog.exceptions.CatalogException;
import org.apache.flink.table.catalog.glue.constants.GlueCatalogConstants;

import org.apache.flink.table.expressions.Expression;
import org.apache.flink.table.expressions.utils.ResolvedExpressionMock;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import software.amazon.awssdk.services.glue.model.Database;
Expand Down Expand Up @@ -165,5 +168,10 @@ public void testExtractTableOwner() {
}

@Test
public void testExpressionString() {}
public void testExpressionString() {
StringBuilder sb = new StringBuilder();
Expression expression = ResolvedExpressionMock.of(DataTypes.INT(), "column1");
GlueUtils.getExpressionString(expression, sb);
Assertions.assertEquals( "column1", sb.toString());
}
}

0 comments on commit f2d5178

Please sign in to comment.