kylin-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From shaofeng...@apache.org
Subject [03/34] incubator-kylin git commit: KYLIN-900 Filter should to use table name and not generated alias
Date Wed, 26 Aug 2015 14:08:26 GMT
KYLIN-900 Filter should to use table name and not generated alias


Project: http://git-wip-us.apache.org/repos/asf/incubator-kylin/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-kylin/commit/7b9bf038
Tree: http://git-wip-us.apache.org/repos/asf/incubator-kylin/tree/7b9bf038
Diff: http://git-wip-us.apache.org/repos/asf/incubator-kylin/diff/7b9bf038

Branch: refs/heads/topn
Commit: 7b9bf038b8f6cf6993161b9dc99b30a45baf72c8
Parents: c3b2b76
Author: Li, Yang <yangli9@ebay.com>
Authored: Mon Aug 24 16:13:38 2015 +0800
Committer: shaofengshi <shaofengshi@apache.org>
Committed: Wed Aug 26 18:06:34 2015 +0800

----------------------------------------------------------------------
 .../org/apache/kylin/job/JoinedFlatTable.java   | 25 +++++++++++++-------
 1 file changed, 16 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/7b9bf038/core-job/src/main/java/org/apache/kylin/job/JoinedFlatTable.java
----------------------------------------------------------------------
diff --git a/core-job/src/main/java/org/apache/kylin/job/JoinedFlatTable.java b/core-job/src/main/java/org/apache/kylin/job/JoinedFlatTable.java
index e6b1294..6ae3ccb 100644
--- a/core-job/src/main/java/org/apache/kylin/job/JoinedFlatTable.java
+++ b/core-job/src/main/java/org/apache/kylin/job/JoinedFlatTable.java
@@ -51,10 +51,6 @@ import org.xml.sax.SAXException;
 
 public class JoinedFlatTable {
 
-    public static final String FACT_TABLE_ALIAS = "FACT_TABLE";
-
-    public static final String LOOKUP_TABLE_ALAIS_PREFIX = "LOOKUP_";
-
     public static String getTableDir(IJoinedFlatTableDesc intermediateTableDesc, String storageDfsDir)
{
         return storageDfsDir + "/" + intermediateTableDesc.getTableName();
     }
@@ -142,20 +138,31 @@ public class JoinedFlatTable {
     private static Map<String, String> buildTableAliasMap(DataModelDesc dataModelDesc)
{
         Map<String, String> tableAliasMap = new HashMap<String, String>();
 
-        tableAliasMap.put(dataModelDesc.getFactTable().toUpperCase(), FACT_TABLE_ALIAS);
+        addTableAlias(dataModelDesc.getFactTable(), tableAliasMap);
 
-        int i = 1;
         for (LookupDesc lookupDesc : dataModelDesc.getLookups()) {
             JoinDesc join = lookupDesc.getJoin();
             if (join != null) {
-                tableAliasMap.put(lookupDesc.getTable().toUpperCase(), LOOKUP_TABLE_ALAIS_PREFIX
+ i);
-                i++;
+                addTableAlias(lookupDesc.getTable(), tableAliasMap);
             }
-
         }
         return tableAliasMap;
     }
 
+    // The table alias used to be "FACT_TABLE" and "LOOKUP_#", but that's too unpredictable
+    // for those who want to write a filter. (KYLIN-900)
+    // Also yet don't support joining the same table more than once, since table name is
the map key.
+    private static void addTableAlias(String table, Map<String, String> tableAliasMap)
{
+        String alias;
+        int cut = table.lastIndexOf('.');
+        if (cut < 0)
+            alias = table;
+        else
+            alias = table.substring(cut + 1);
+
+        tableAliasMap.put(table, alias);
+    }
+
     private static void appendJoinStatement(IJoinedFlatTableDesc intermediateTableDesc, StringBuilder
sql, Map<String, String> tableAliasMap) {
         Set<String> dimTableCache = new HashSet<String>();
 


Mime
View raw message