Skip to content
Merged
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 @@ -25,6 +25,7 @@
import org.apache.doris.catalog.PartitionType;
import org.apache.doris.common.AnalysisException;
import org.apache.doris.common.DdlException;
import org.apache.doris.common.util.SqlUtils;
import org.apache.doris.common.util.Util;
import org.apache.doris.datasource.ExternalTable;
import org.apache.doris.datasource.SchemaCacheKey;
Expand Down Expand Up @@ -75,6 +76,7 @@ public class IcebergExternalTable extends ExternalTable implements MTMVRelatedTa
private boolean isValidRelatedTable = false;
private boolean isView;
private static final String ENGINE_PROP_NAME = "engine-name";
private static final String TABLE_COMMENT_PROP = "comment";

public IcebergExternalTable(long id, String name, String remoteName, IcebergExternalCatalog catalog,
IcebergExternalDatabase db) {
Expand Down Expand Up @@ -146,6 +148,17 @@ public Table getIcebergTable() {
return IcebergUtils.getIcebergTable(this);
}

@Override
public String getComment() {
return properties().getOrDefault(TABLE_COMMENT_PROP, "");
}

@Override
public String getComment(boolean escapeQuota) {
String comment = getComment();
return escapeQuota ? SqlUtils.escapeQuota(comment) : comment;
}

@Override
public void beforeMTMVRefresh(MTMV mtmv) throws DdlException {
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,22 @@ private IcebergExternalTable createSpyTable() {
return spy;
}

@Test
public void testGetComment() {
IcebergExternalTable spy = createSpyTable();
Map<String, String> properties = Maps.newHashMap();
properties.put("comment", "my-table-comment");
Mockito.when(icebergTable.properties()).thenReturn(properties);

Assertions.assertEquals("my-table-comment", spy.getComment());

properties.put("comment", "comment with \"quote\"");
Assertions.assertEquals("comment with \\\"quote\\\"", spy.getComment(true));

properties.remove("comment");
Assertions.assertEquals("", spy.getComment());
}

/** Creates a mock Transform with the given canonical toString() value.
* Also stubs isIdentity() and isVoid() based on the value. */
@SuppressWarnings({"unchecked", "rawtypes"})
Expand Down Expand Up @@ -398,4 +414,3 @@ public void testGetPartitionSpecSqlUnresolvableColumnSkipped() {
Assertions.assertEquals("", spy.getPartitionSpecSql());
}
}

Loading