Skip to content

Commit

Permalink
Merge 4973350 into 2b0e79c
Browse files Browse the repository at this point in the history
  • Loading branch information
akashrn5 committed Jun 22, 2019
2 parents 2b0e79c + 4973350 commit 5f45f2e
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ public synchronized void registerDataMapCatalog(DataMapProvider dataMapProvider,
if (dataMapCatalog == null) {
dataMapCatalog = dataMapProvider.createDataMapCatalog();
if (dataMapCatalog != null) {
dataMapCatalogs.put(name, dataMapCatalog);
dataMapCatalogs.put(name.toLowerCase(), dataMapCatalog);
dataMapCatalog.registerSchema(dataMapSchema);
}
} else {
Expand Down Expand Up @@ -291,7 +291,7 @@ private void initializeDataMapCatalogs(DataMapProvider dataMapProvider) throws I
if (null == dataMapCatalog) {
throw new RuntimeException("Internal Error.");
}
dataMapCatalogs.put(schema.getProviderName(), dataMapCatalog);
dataMapCatalogs.put(schema.getProviderName().toLowerCase(), dataMapCatalog);
}
try {
dataMapCatalog.registerSchema(schema);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,23 @@ object MVUtil {
}
case a@Alias(_, name) =>
checkIfComplexDataTypeExists(a)
val arrayBuffer: ArrayBuffer[ColumnTableRelation] = new ArrayBuffer[ColumnTableRelation]()
a.collect {
case attr: AttributeReference =>
val carbonTable = getCarbonTable(logicalRelation, attr)
if (null != carbonTable) {
val relation = getColumnRelation(attr.name,
carbonTable.getAbsoluteTableIdentifier.getCarbonTableIdentifier.getTableId,
carbonTable.getAbsoluteTableIdentifier.getCarbonTableIdentifier.getTableName,
carbonTable.getAbsoluteTableIdentifier.getCarbonTableIdentifier.getDatabaseName,
carbonTable)
if (null != relation) {
arrayBuffer += relation
}
}
}
fieldToDataMapFieldMap +=
getFieldToDataMapFields(a.name, a.dataType, None, "arithmetic", arrayBuffer, "")
}
fieldToDataMapFieldMap
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1136,6 +1136,22 @@ class MVCreateTestCase extends QueryTest with BeforeAndAfterAll {
assert(TestUtil.verifyMVDataMap(analyzed1, "same_mv"))
}

test("test cast expression with mv") {
sql("drop table IF EXISTS maintable")
sql("create table maintable (m_month bigint, c_code string, " +
"c_country smallint, d_dollar_value double, q_quantity double, u_unit smallint, b_country smallint, i_id int, y_year smallint) stored by 'carbondata'")
sql("insert into maintable select 10, 'xxx', 123, 456, 45, 5, 23, 1, 2000")
sql("drop datamap if exists da_cast")
sql(
"create datamap da_cast using 'mv' as select cast(floor((m_month +1000) / 900) * 900 - 2000 AS INT) as a, c_code as abc,m_month from maintable")
val df1 = sql(
" select cast(floor((m_month +1000) / 900) * 900 - 2000 AS INT) as a ,c_code as abc from maintable")
val df2 = sql(
" select cast(floor((m_month +1000) / 900) * 900 - 2000 AS INT),c_code as abc from maintable")
val analyzed1 = df1.queryExecution.analyzed
assert(TestUtil.verifyMVDataMap(analyzed1, "da_cast"))
}


def drop(): Unit = {
sql("drop table IF EXISTS fact_table1")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ object HarmonizedRelation {
case alias: Alias =>
alias.child.isInstanceOf[AttributeReference] ||
alias.child.isInstanceOf[Literal] ||
alias.child.isInstanceOf[Expression] ||
(alias.child match {
case AggregateExpression(First(_, _), _, _, _) => true
case AggregateExpression(Last(_, _), _, _, _) => true
Expand Down

0 comments on commit 5f45f2e

Please sign in to comment.