mchades commented on code in PR #10982:
URL: https://github.com/apache/gravitino/pull/10982#discussion_r3207442794
##########
common/src/main/java/org/apache/gravitino/dto/rel/SQLRepresentationDTO.java:
##########
@@ -18,53 +18,170 @@
*/
package org.apache.gravitino.dto.rel;
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
-import lombok.EqualsAndHashCode;
-import lombok.Getter;
+import com.google.common.base.Preconditions;
+import java.util.Objects;
+import org.apache.commons.lang3.StringUtils;
import org.apache.gravitino.rel.Representation;
import org.apache.gravitino.rel.SQLRepresentation;
-/** DTO for SQL representation. */
-@Getter
-@EqualsAndHashCode(callSuper = true)
-public class SQLRepresentationDTO extends RepresentationDTO {
+/**
+ * A DTO mirroring {@link org.apache.gravitino.rel.SQLRepresentation}.
Represents a SQL-based view
+ * definition for a particular dialect.
+ */
+@JsonIgnoreProperties(ignoreUnknown = true)
+public final class SQLRepresentationDTO extends RepresentationDTO {
+
+ @JsonProperty("type")
+ private final String type = Representation.TYPE_SQL;
@JsonProperty("dialect")
private String dialect;
@JsonProperty("sql")
private String sql;
- private SQLRepresentationDTO() {}
+ private SQLRepresentationDTO() {
+ super();
+ }
+
+ private SQLRepresentationDTO(String dialect, String sql) {
+ this.dialect = dialect;
+ this.sql = sql;
+ }
/**
- * Creates a SQL representation DTO.
+ * Creates a new {@link Builder}.
*
- * @param dialect SQL dialect.
- * @param sql SQL body.
+ * @return A new builder instance.
*/
- public SQLRepresentationDTO(String dialect, String sql) {
- this.dialect = dialect;
- this.sql = sql;
+ public static Builder builder() {
+ return new Builder();
+ }
+
+ /**
+ * Creates a new {@link SQLRepresentationDTO} from a {@link
SQLRepresentation} domain object.
+ *
+ * @param sqlRepresentation The SQL representation domain object.
+ * @return The SQL representation DTO.
+ */
+ public static SQLRepresentationDTO fromSQLRepresentation(SQLRepresentation
sqlRepresentation) {
+ return builder()
+ .withDialect(sqlRepresentation.dialect())
+ .withSql(sqlRepresentation.sql())
+ .build();
}
@Override
public String type() {
- return Representation.TYPE_SQL;
+ return type;
}
- @Override
- public SQLRepresentation toRepresentation() {
- return
SQLRepresentation.builder().withDialect(dialect).withSql(sql).build();
+ /**
+ * Returns the SQL dialect of this representation.
+ *
+ * @return The dialect identifier.
+ */
+ public String dialect() {
+ return dialect;
+ }
+
+ /**
+ * Returns the SQL dialect of this representation.
+ *
+ * @return The dialect identifier.
+ */
+ public String getDialect() {
Review Comment:
Fixed. Removed the redundant `getDialect()` / `getSql()` accessors and kept
`dialect()` / `sql()` only. This avoids duplicated access paths and keeps the
API consistent.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]