From 9b469996a49fc73a9bb213bac09193b8a4f6cdd4 Mon Sep 17 00:00:00 2001 From: hchen04 Date: Wed, 19 Feb 2020 15:48:36 -0800 Subject: [PATCH 1/3] sourceColumn --- .../datastores/aggregation/QueryEngine.java | 2 ++ .../aggregation/metadata/MetaDataStore.java | 12 ++++++++++++ .../aggregation/metadata/models/Column.java | 10 ++++++++++ .../queryengines/sql/metadata/SQLDimension.java | 16 ++++++++++++++++ .../sql/metadata/SQLTimeDimension.java | 16 ++++++++++++++++ .../aggregation/framework/SQLUnitTest.java | 4 +++- .../AggregationDataStoreIntegrationTest.java | 3 +++ 7 files changed, 62 insertions(+), 1 deletion(-) diff --git a/elide-datastore/elide-datastore-aggregation/src/main/java/com/yahoo/elide/datastores/aggregation/QueryEngine.java b/elide-datastore/elide-datastore-aggregation/src/main/java/com/yahoo/elide/datastores/aggregation/QueryEngine.java index 43e8be5cee..a8c2327580 100644 --- a/elide-datastore/elide-datastore-aggregation/src/main/java/com/yahoo/elide/datastores/aggregation/QueryEngine.java +++ b/elide-datastore/elide-datastore-aggregation/src/main/java/com/yahoo/elide/datastores/aggregation/QueryEngine.java @@ -111,6 +111,8 @@ private void populateMetaData(MetaDataStore metaDataStore) { metaDataStore.getModelsToBind().stream() .map(model -> constructTable(model, metadataDictionary)) .forEach(metaDataStore::addTable); + + metaDataStore.resolveSourceColumn(); } /** diff --git a/elide-datastore/elide-datastore-aggregation/src/main/java/com/yahoo/elide/datastores/aggregation/metadata/MetaDataStore.java b/elide-datastore/elide-datastore-aggregation/src/main/java/com/yahoo/elide/datastores/aggregation/metadata/MetaDataStore.java index 6b9c3294d8..df93d3fdb4 100644 --- a/elide-datastore/elide-datastore-aggregation/src/main/java/com/yahoo/elide/datastores/aggregation/metadata/MetaDataStore.java +++ b/elide-datastore/elide-datastore-aggregation/src/main/java/com/yahoo/elide/datastores/aggregation/metadata/MetaDataStore.java @@ -24,6 +24,7 @@ import org.hibernate.annotations.Subselect; +import javafx.util.Pair; import lombok.Getter; import java.lang.annotation.Annotation; @@ -169,4 +170,15 @@ public static boolean isMetricField(EntityDictionary dictionary, Class cls, S public static boolean isTableJoin(Class cls, String fieldName, EntityDictionary dictionary) { return dictionary.getAttributeOrRelationAnnotation(cls, Join.class, fieldName) != null; } + + public void resolveSourceColumn() { + getMetaData(Table.class).forEach(table -> table.getColumns().forEach(column -> { + Pair sourceTableAndColumn = column.getSourceTableAndColumn(); + Table sourceTable = (Table) dataStore.get(Table.class).get(sourceTableAndColumn.getKey()); + Column sourceColumn = column instanceof Metric + ? sourceTable.getMetric(sourceTableAndColumn.getValue()) + : sourceTable.getDimension(sourceTableAndColumn.getValue()); + column.setSourceColumn(sourceColumn); + })); + } } diff --git a/elide-datastore/elide-datastore-aggregation/src/main/java/com/yahoo/elide/datastores/aggregation/metadata/models/Column.java b/elide-datastore/elide-datastore-aggregation/src/main/java/com/yahoo/elide/datastores/aggregation/metadata/models/Column.java index 8b34693590..eae701a477 100644 --- a/elide-datastore/elide-datastore-aggregation/src/main/java/com/yahoo/elide/datastores/aggregation/metadata/models/Column.java +++ b/elide-datastore/elide-datastore-aggregation/src/main/java/com/yahoo/elide/datastores/aggregation/metadata/models/Column.java @@ -11,6 +11,7 @@ import com.yahoo.elide.datastores.aggregation.annotation.Meta; import com.yahoo.elide.datastores.aggregation.metadata.enums.ValueType; +import javafx.util.Pair; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.ToString; @@ -45,6 +46,11 @@ public abstract class Column { private ValueType valueType; + @ToOne + @ToString.Exclude + @EqualsAndHashCode.Exclude + private Column sourceColumn; + @ToString.Exclude private Set columnTags; @@ -83,4 +89,8 @@ public static ValueType getValueType(Class tableClass, String fieldName, Enti } } } + + public Pair getSourceTableAndColumn() { + return new Pair<>(table.getId(), getName()); + } } diff --git a/elide-datastore/elide-datastore-aggregation/src/main/java/com/yahoo/elide/datastores/aggregation/queryengines/sql/metadata/SQLDimension.java b/elide-datastore/elide-datastore-aggregation/src/main/java/com/yahoo/elide/datastores/aggregation/queryengines/sql/metadata/SQLDimension.java index 7381063f82..9330a4a32b 100644 --- a/elide-datastore/elide-datastore-aggregation/src/main/java/com/yahoo/elide/datastores/aggregation/queryengines/sql/metadata/SQLDimension.java +++ b/elide-datastore/elide-datastore-aggregation/src/main/java/com/yahoo/elide/datastores/aggregation/queryengines/sql/metadata/SQLDimension.java @@ -9,11 +9,13 @@ import static com.yahoo.elide.datastores.aggregation.queryengines.sql.SQLQueryEngine.getClassAlias; import com.yahoo.elide.core.EntityDictionary; +import com.yahoo.elide.core.Path; import com.yahoo.elide.datastores.aggregation.core.JoinPath; import com.yahoo.elide.datastores.aggregation.metadata.models.Dimension; import com.yahoo.elide.datastores.aggregation.metadata.models.Table; import com.yahoo.elide.datastores.aggregation.queryengines.sql.annotation.JoinTo; +import javafx.util.Pair; import lombok.Getter; /** @@ -26,6 +28,8 @@ public class SQLDimension extends Dimension implements SQLColumn { @Getter private final JoinPath joinPath; + private EntityDictionary metadataDictionary; + public SQLDimension(Table table, String fieldName, EntityDictionary dictionary) { super(table, fieldName, dictionary); Class tableClass = dictionary.getEntityClass(table.getId()); @@ -40,5 +44,17 @@ public SQLDimension(Table table, String fieldName, EntityDictionary dictionary) this.reference = generateColumnReference(path, dictionary); this.joinPath = path; } + + this.metadataDictionary = dictionary; + } + + @Override + public Pair getSourceTableAndColumn() { + if (joinPath == null) { + return super.getSourceTableAndColumn(); + } else { + Path.PathElement last = joinPath.lastElement().get(); + return new Pair<>(metadataDictionary.getJsonAliasFor(last.getType()), last.getFieldName()); + } } } diff --git a/elide-datastore/elide-datastore-aggregation/src/main/java/com/yahoo/elide/datastores/aggregation/queryengines/sql/metadata/SQLTimeDimension.java b/elide-datastore/elide-datastore-aggregation/src/main/java/com/yahoo/elide/datastores/aggregation/queryengines/sql/metadata/SQLTimeDimension.java index fff0a73be0..705f8e7d6d 100644 --- a/elide-datastore/elide-datastore-aggregation/src/main/java/com/yahoo/elide/datastores/aggregation/queryengines/sql/metadata/SQLTimeDimension.java +++ b/elide-datastore/elide-datastore-aggregation/src/main/java/com/yahoo/elide/datastores/aggregation/queryengines/sql/metadata/SQLTimeDimension.java @@ -9,11 +9,13 @@ import static com.yahoo.elide.datastores.aggregation.queryengines.sql.SQLQueryEngine.getClassAlias; import com.yahoo.elide.core.EntityDictionary; +import com.yahoo.elide.core.Path; import com.yahoo.elide.datastores.aggregation.core.JoinPath; import com.yahoo.elide.datastores.aggregation.metadata.models.Table; import com.yahoo.elide.datastores.aggregation.metadata.models.TimeDimension; import com.yahoo.elide.datastores.aggregation.queryengines.sql.annotation.JoinTo; +import javafx.util.Pair; import lombok.Getter; /** @@ -26,6 +28,8 @@ public class SQLTimeDimension extends TimeDimension implements SQLColumn { @Getter private final JoinPath joinPath; + private EntityDictionary metadataDictionary; + public SQLTimeDimension(Table table, String fieldName, EntityDictionary dictionary) { super(table, fieldName, dictionary); Class tableClass = dictionary.getEntityClass(table.getId()); @@ -40,5 +44,17 @@ public SQLTimeDimension(Table table, String fieldName, EntityDictionary dictiona this.reference = generateColumnReference(path, dictionary); this.joinPath = path; } + + this.metadataDictionary = dictionary; + } + + @Override + public Pair getSourceTableAndColumn() { + if (joinPath == null) { + return super.getSourceTableAndColumn(); + } else { + Path.PathElement last = joinPath.lastElement().get(); + return new Pair<>(metadataDictionary.getJsonAliasFor(last.getType()), last.getFieldName()); + } } } diff --git a/elide-datastore/elide-datastore-aggregation/src/test/java/com/yahoo/elide/datastores/aggregation/framework/SQLUnitTest.java b/elide-datastore/elide-datastore-aggregation/src/test/java/com/yahoo/elide/datastores/aggregation/framework/SQLUnitTest.java index 6fc0b28798..d8141b5b36 100644 --- a/elide-datastore/elide-datastore-aggregation/src/test/java/com/yahoo/elide/datastores/aggregation/framework/SQLUnitTest.java +++ b/elide-datastore/elide-datastore-aggregation/src/test/java/com/yahoo/elide/datastores/aggregation/framework/SQLUnitTest.java @@ -39,7 +39,7 @@ public abstract class SQLUnitTest { protected static Table playerStatsTable; protected static EntityDictionary dictionary; protected static RSQLFilterDialect filterParser; - protected static MetaDataStore metaDataStore = new MetaDataStore(); + protected static MetaDataStore metaDataStore; protected static final Country HONG_KONG = new Country(); protected static final Country USA = new Country(); @@ -49,6 +49,8 @@ public abstract class SQLUnitTest { protected static QueryEngine engine; public static void init() { + metaDataStore = new MetaDataStore(); + emf = Persistence.createEntityManagerFactory("aggregationStore"); dictionary = new EntityDictionary(new HashMap<>()); dictionary.bindEntity(PlayerStatsWithView.class); diff --git a/elide-datastore/elide-datastore-aggregation/src/test/java/com/yahoo/elide/datastores/aggregation/integration/AggregationDataStoreIntegrationTest.java b/elide-datastore/elide-datastore-aggregation/src/test/java/com/yahoo/elide/datastores/aggregation/integration/AggregationDataStoreIntegrationTest.java index 0b4f981854..bd1eba8c73 100644 --- a/elide-datastore/elide-datastore-aggregation/src/test/java/com/yahoo/elide/datastores/aggregation/integration/AggregationDataStoreIntegrationTest.java +++ b/elide-datastore/elide-datastore-aggregation/src/test/java/com/yahoo/elide/datastores/aggregation/integration/AggregationDataStoreIntegrationTest.java @@ -690,6 +690,7 @@ public void metaDataTest() { .statusCode(HttpStatus.SC_OK) .body("data.attributes.name", equalTo("playerName")) .body("data.attributes.valueType", equalTo("TEXT")) + .body("data.relationships.sourceColumn.data.id", equalTo("player.name")) .body("data.relationships.table.data.id", equalTo("playerStats")); given() @@ -699,6 +700,7 @@ public void metaDataTest() { .statusCode(HttpStatus.SC_OK) .body("data.attributes.name", equalTo("lowScore")) .body("data.attributes.valueType", equalTo("INTEGER")) + .body("data.relationships.sourceColumn.data.id", equalTo("playerStats.lowScore")) .body("data.relationships.table.data.id", equalTo("playerStats")) .body("data.relationships.metricFunction.data.id", equalTo("playerStats.lowScore[min]")) .body("included.id", hasItem("playerStats.lowScore[min]")) @@ -713,6 +715,7 @@ public void metaDataTest() { .statusCode(HttpStatus.SC_OK) .body("data.attributes.name", equalTo("recordedDate")) .body("data.attributes.valueType", equalTo("TIME")) + .body("data.relationships.sourceColumn.data.id", equalTo("playerStats.recordedDate")) .body("data.relationships.table.data.id", equalTo("playerStats")) .body( "data.relationships.supportedGrains.data.id", From a0f481646a50edd5f342d2de8f1a9ab58538aedb Mon Sep 17 00:00:00 2001 From: hchen04 Date: Thu, 20 Feb 2020 13:33:37 -0800 Subject: [PATCH 2/3] address comment --- .../queryengines/sql/metadata/SQLColumn.java | 19 +++++++++++++++++++ .../sql/metadata/SQLDimension.java | 9 ++------- .../sql/metadata/SQLTimeDimension.java | 9 ++------- 3 files changed, 23 insertions(+), 14 deletions(-) diff --git a/elide-datastore/elide-datastore-aggregation/src/main/java/com/yahoo/elide/datastores/aggregation/queryengines/sql/metadata/SQLColumn.java b/elide-datastore/elide-datastore-aggregation/src/main/java/com/yahoo/elide/datastores/aggregation/queryengines/sql/metadata/SQLColumn.java index 6e5f734cc3..c959cd56ca 100644 --- a/elide-datastore/elide-datastore-aggregation/src/main/java/com/yahoo/elide/datastores/aggregation/queryengines/sql/metadata/SQLColumn.java +++ b/elide-datastore/elide-datastore-aggregation/src/main/java/com/yahoo/elide/datastores/aggregation/queryengines/sql/metadata/SQLColumn.java @@ -5,13 +5,32 @@ */ package com.yahoo.elide.datastores.aggregation.queryengines.sql.metadata; +import com.yahoo.elide.core.EntityDictionary; +import com.yahoo.elide.core.Path; import com.yahoo.elide.datastores.aggregation.core.JoinPath; +import com.yahoo.elide.datastores.aggregation.metadata.models.Table; + +import javafx.util.Pair; /** * Column with physical SQL information like reference and join to path. */ public interface SQLColumn { + Table getTable(); + + String getName(); + String getReference(); JoinPath getJoinPath(); + + default Pair getSourceTableAndColumn(EntityDictionary metadataDictionary) { + JoinPath joinPath = getJoinPath(); + if (joinPath == null) { + return new Pair<>(getTable().getId(), getName()); + } else { + Path.PathElement last = joinPath.lastElement().get(); + return new Pair<>(metadataDictionary.getJsonAliasFor(last.getType()), last.getFieldName()); + } + } } diff --git a/elide-datastore/elide-datastore-aggregation/src/main/java/com/yahoo/elide/datastores/aggregation/queryengines/sql/metadata/SQLDimension.java b/elide-datastore/elide-datastore-aggregation/src/main/java/com/yahoo/elide/datastores/aggregation/queryengines/sql/metadata/SQLDimension.java index 9330a4a32b..c879b6462d 100644 --- a/elide-datastore/elide-datastore-aggregation/src/main/java/com/yahoo/elide/datastores/aggregation/queryengines/sql/metadata/SQLDimension.java +++ b/elide-datastore/elide-datastore-aggregation/src/main/java/com/yahoo/elide/datastores/aggregation/queryengines/sql/metadata/SQLDimension.java @@ -9,7 +9,6 @@ import static com.yahoo.elide.datastores.aggregation.queryengines.sql.SQLQueryEngine.getClassAlias; import com.yahoo.elide.core.EntityDictionary; -import com.yahoo.elide.core.Path; import com.yahoo.elide.datastores.aggregation.core.JoinPath; import com.yahoo.elide.datastores.aggregation.metadata.models.Dimension; import com.yahoo.elide.datastores.aggregation.metadata.models.Table; @@ -28,6 +27,7 @@ public class SQLDimension extends Dimension implements SQLColumn { @Getter private final JoinPath joinPath; + @Getter private EntityDictionary metadataDictionary; public SQLDimension(Table table, String fieldName, EntityDictionary dictionary) { @@ -50,11 +50,6 @@ public SQLDimension(Table table, String fieldName, EntityDictionary dictionary) @Override public Pair getSourceTableAndColumn() { - if (joinPath == null) { - return super.getSourceTableAndColumn(); - } else { - Path.PathElement last = joinPath.lastElement().get(); - return new Pair<>(metadataDictionary.getJsonAliasFor(last.getType()), last.getFieldName()); - } + return getSourceTableAndColumn(metadataDictionary); } } diff --git a/elide-datastore/elide-datastore-aggregation/src/main/java/com/yahoo/elide/datastores/aggregation/queryengines/sql/metadata/SQLTimeDimension.java b/elide-datastore/elide-datastore-aggregation/src/main/java/com/yahoo/elide/datastores/aggregation/queryengines/sql/metadata/SQLTimeDimension.java index 705f8e7d6d..145772add6 100644 --- a/elide-datastore/elide-datastore-aggregation/src/main/java/com/yahoo/elide/datastores/aggregation/queryengines/sql/metadata/SQLTimeDimension.java +++ b/elide-datastore/elide-datastore-aggregation/src/main/java/com/yahoo/elide/datastores/aggregation/queryengines/sql/metadata/SQLTimeDimension.java @@ -9,7 +9,6 @@ import static com.yahoo.elide.datastores.aggregation.queryengines.sql.SQLQueryEngine.getClassAlias; import com.yahoo.elide.core.EntityDictionary; -import com.yahoo.elide.core.Path; import com.yahoo.elide.datastores.aggregation.core.JoinPath; import com.yahoo.elide.datastores.aggregation.metadata.models.Table; import com.yahoo.elide.datastores.aggregation.metadata.models.TimeDimension; @@ -28,6 +27,7 @@ public class SQLTimeDimension extends TimeDimension implements SQLColumn { @Getter private final JoinPath joinPath; + @Getter private EntityDictionary metadataDictionary; public SQLTimeDimension(Table table, String fieldName, EntityDictionary dictionary) { @@ -50,11 +50,6 @@ public SQLTimeDimension(Table table, String fieldName, EntityDictionary dictiona @Override public Pair getSourceTableAndColumn() { - if (joinPath == null) { - return super.getSourceTableAndColumn(); - } else { - Path.PathElement last = joinPath.lastElement().get(); - return new Pair<>(metadataDictionary.getJsonAliasFor(last.getType()), last.getFieldName()); - } + return getSourceTableAndColumn(metadataDictionary); } } From 94e4d9d0eb78082a47d88bd66a3df2f782f1d389 Mon Sep 17 00:00:00 2001 From: hchen04 Date: Thu, 20 Feb 2020 14:48:41 -0800 Subject: [PATCH 3/3] change to sourcePath --- .../aggregation/metadata/MetaDataStore.java | 27 ++++++++++++------- .../aggregation/metadata/models/Column.java | 16 ++++++++--- .../queryengines/sql/metadata/SQLColumn.java | 14 ---------- .../sql/metadata/SQLDimension.java | 6 ++--- .../sql/metadata/SQLTimeDimension.java | 6 ++--- 5 files changed, 37 insertions(+), 32 deletions(-) diff --git a/elide-datastore/elide-datastore-aggregation/src/main/java/com/yahoo/elide/datastores/aggregation/metadata/MetaDataStore.java b/elide-datastore/elide-datastore-aggregation/src/main/java/com/yahoo/elide/datastores/aggregation/metadata/MetaDataStore.java index df93d3fdb4..f28670d47a 100644 --- a/elide-datastore/elide-datastore-aggregation/src/main/java/com/yahoo/elide/datastores/aggregation/metadata/MetaDataStore.java +++ b/elide-datastore/elide-datastore-aggregation/src/main/java/com/yahoo/elide/datastores/aggregation/metadata/MetaDataStore.java @@ -6,6 +6,7 @@ package com.yahoo.elide.datastores.aggregation.metadata; import com.yahoo.elide.core.EntityDictionary; +import com.yahoo.elide.core.Path; import com.yahoo.elide.core.datastore.inmemory.HashMapDataStore; import com.yahoo.elide.core.exceptions.DuplicateMappingException; import com.yahoo.elide.datastores.aggregation.AggregationDataStore; @@ -24,7 +25,6 @@ import org.hibernate.annotations.Subselect; -import javafx.util.Pair; import lombok.Getter; import java.lang.annotation.Annotation; @@ -171,14 +171,23 @@ public static boolean isTableJoin(Class cls, String fieldName, EntityDictiona return dictionary.getAttributeOrRelationAnnotation(cls, Join.class, fieldName) != null; } + /** + * Resolve source columns for all Columns in all Tables. + */ public void resolveSourceColumn() { - getMetaData(Table.class).forEach(table -> table.getColumns().forEach(column -> { - Pair sourceTableAndColumn = column.getSourceTableAndColumn(); - Table sourceTable = (Table) dataStore.get(Table.class).get(sourceTableAndColumn.getKey()); - Column sourceColumn = column instanceof Metric - ? sourceTable.getMetric(sourceTableAndColumn.getValue()) - : sourceTable.getDimension(sourceTableAndColumn.getValue()); - column.setSourceColumn(sourceColumn); - })); + getMetaData(Table.class).forEach(table -> + table.getColumns().forEach(column -> { + Path sourcePath = column.getSourcePath(dictionary); + Path.PathElement source = sourcePath.lastElement().get(); + + Table sourceTable = (Table) dataStore.get(Table.class) + .get(dictionary.getJsonAliasFor(source.getType())); + + Column sourceColumn = column instanceof Metric + ? sourceTable.getMetric(source.getFieldName()) + : sourceTable.getDimension(source.getFieldName()); + column.setSourceColumn(sourceColumn); + }) + ); } } diff --git a/elide-datastore/elide-datastore-aggregation/src/main/java/com/yahoo/elide/datastores/aggregation/metadata/models/Column.java b/elide-datastore/elide-datastore-aggregation/src/main/java/com/yahoo/elide/datastores/aggregation/metadata/models/Column.java index eae701a477..0637d79a86 100644 --- a/elide-datastore/elide-datastore-aggregation/src/main/java/com/yahoo/elide/datastores/aggregation/metadata/models/Column.java +++ b/elide-datastore/elide-datastore-aggregation/src/main/java/com/yahoo/elide/datastores/aggregation/metadata/models/Column.java @@ -8,14 +8,15 @@ import com.yahoo.elide.annotation.Include; import com.yahoo.elide.annotation.ToOne; import com.yahoo.elide.core.EntityDictionary; +import com.yahoo.elide.core.Path; import com.yahoo.elide.datastores.aggregation.annotation.Meta; import com.yahoo.elide.datastores.aggregation.metadata.enums.ValueType; -import javafx.util.Pair; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.ToString; +import java.util.Collections; import java.util.Date; import java.util.HashSet; import java.util.Set; @@ -90,7 +91,16 @@ public static ValueType getValueType(Class tableClass, String fieldName, Enti } } - public Pair getSourceTableAndColumn() { - return new Pair<>(table.getId(), getName()); + /** + * Return a Path that navigate to the source of this column. + * + * @param metadataDictionary metadata dictionary + * @return Path to source column + */ + public Path getSourcePath(EntityDictionary metadataDictionary) { + Class tableCls = metadataDictionary.getEntityClass(table.getId()); + Class columnCls = metadataDictionary.getParameterizedType(tableCls, getName()); + + return new Path(Collections.singletonList(new Path.PathElement(tableCls, columnCls, getName()))); } } diff --git a/elide-datastore/elide-datastore-aggregation/src/main/java/com/yahoo/elide/datastores/aggregation/queryengines/sql/metadata/SQLColumn.java b/elide-datastore/elide-datastore-aggregation/src/main/java/com/yahoo/elide/datastores/aggregation/queryengines/sql/metadata/SQLColumn.java index c959cd56ca..3a7bf2d53f 100644 --- a/elide-datastore/elide-datastore-aggregation/src/main/java/com/yahoo/elide/datastores/aggregation/queryengines/sql/metadata/SQLColumn.java +++ b/elide-datastore/elide-datastore-aggregation/src/main/java/com/yahoo/elide/datastores/aggregation/queryengines/sql/metadata/SQLColumn.java @@ -5,13 +5,9 @@ */ package com.yahoo.elide.datastores.aggregation.queryengines.sql.metadata; -import com.yahoo.elide.core.EntityDictionary; -import com.yahoo.elide.core.Path; import com.yahoo.elide.datastores.aggregation.core.JoinPath; import com.yahoo.elide.datastores.aggregation.metadata.models.Table; -import javafx.util.Pair; - /** * Column with physical SQL information like reference and join to path. */ @@ -23,14 +19,4 @@ public interface SQLColumn { String getReference(); JoinPath getJoinPath(); - - default Pair getSourceTableAndColumn(EntityDictionary metadataDictionary) { - JoinPath joinPath = getJoinPath(); - if (joinPath == null) { - return new Pair<>(getTable().getId(), getName()); - } else { - Path.PathElement last = joinPath.lastElement().get(); - return new Pair<>(metadataDictionary.getJsonAliasFor(last.getType()), last.getFieldName()); - } - } } diff --git a/elide-datastore/elide-datastore-aggregation/src/main/java/com/yahoo/elide/datastores/aggregation/queryengines/sql/metadata/SQLDimension.java b/elide-datastore/elide-datastore-aggregation/src/main/java/com/yahoo/elide/datastores/aggregation/queryengines/sql/metadata/SQLDimension.java index c879b6462d..dccd947500 100644 --- a/elide-datastore/elide-datastore-aggregation/src/main/java/com/yahoo/elide/datastores/aggregation/queryengines/sql/metadata/SQLDimension.java +++ b/elide-datastore/elide-datastore-aggregation/src/main/java/com/yahoo/elide/datastores/aggregation/queryengines/sql/metadata/SQLDimension.java @@ -9,12 +9,12 @@ import static com.yahoo.elide.datastores.aggregation.queryengines.sql.SQLQueryEngine.getClassAlias; import com.yahoo.elide.core.EntityDictionary; +import com.yahoo.elide.core.Path; import com.yahoo.elide.datastores.aggregation.core.JoinPath; import com.yahoo.elide.datastores.aggregation.metadata.models.Dimension; import com.yahoo.elide.datastores.aggregation.metadata.models.Table; import com.yahoo.elide.datastores.aggregation.queryengines.sql.annotation.JoinTo; -import javafx.util.Pair; import lombok.Getter; /** @@ -49,7 +49,7 @@ public SQLDimension(Table table, String fieldName, EntityDictionary dictionary) } @Override - public Pair getSourceTableAndColumn() { - return getSourceTableAndColumn(metadataDictionary); + public Path getSourcePath(EntityDictionary metadataDictionary) { + return joinPath == null ? super.getSourcePath(metadataDictionary) : joinPath; } } diff --git a/elide-datastore/elide-datastore-aggregation/src/main/java/com/yahoo/elide/datastores/aggregation/queryengines/sql/metadata/SQLTimeDimension.java b/elide-datastore/elide-datastore-aggregation/src/main/java/com/yahoo/elide/datastores/aggregation/queryengines/sql/metadata/SQLTimeDimension.java index 145772add6..494d1e3a14 100644 --- a/elide-datastore/elide-datastore-aggregation/src/main/java/com/yahoo/elide/datastores/aggregation/queryengines/sql/metadata/SQLTimeDimension.java +++ b/elide-datastore/elide-datastore-aggregation/src/main/java/com/yahoo/elide/datastores/aggregation/queryengines/sql/metadata/SQLTimeDimension.java @@ -9,12 +9,12 @@ import static com.yahoo.elide.datastores.aggregation.queryengines.sql.SQLQueryEngine.getClassAlias; import com.yahoo.elide.core.EntityDictionary; +import com.yahoo.elide.core.Path; import com.yahoo.elide.datastores.aggregation.core.JoinPath; import com.yahoo.elide.datastores.aggregation.metadata.models.Table; import com.yahoo.elide.datastores.aggregation.metadata.models.TimeDimension; import com.yahoo.elide.datastores.aggregation.queryengines.sql.annotation.JoinTo; -import javafx.util.Pair; import lombok.Getter; /** @@ -49,7 +49,7 @@ public SQLTimeDimension(Table table, String fieldName, EntityDictionary dictiona } @Override - public Pair getSourceTableAndColumn() { - return getSourceTableAndColumn(metadataDictionary); + public Path getSourcePath(EntityDictionary metadataDictionary) { + return joinPath == null ? super.getSourcePath(metadataDictionary) : joinPath; } }