浏览代码

HPCC-25854 WsSQL nested dataset support should be versioned

- Versions nested dataset related interface changes
- Improves logic rejecting normalized column arithmatic


Signed-off-by: Rodrigo Pastrana <rodrigo.pastrana@lexisnexisrisk.com>
Rodrigo Pastrana 4 年之前
父节点
当前提交
37eb4f448a

+ 2 - 2
esp/scm/ws_sql.ecm

@@ -25,7 +25,7 @@ ESPStruct HPCCColumn
 {
    string Name;
    string Type;
-   ESParray<ESPstruct HPCCColumn, Column> Columns;
+   [min_ver("3.06")] ESParray<ESPstruct HPCCColumn, Column> Columns;
 };
 
 ESPStruct HPCCTable
@@ -328,7 +328,7 @@ ESPresponse CreateTableAndLoadResponse
     ESPstruct ECLWorkunit Workunit;
 };
 
-ESPservice [version("3.05"), default_client_version("3.05"), auth_feature("DEFERRED"), exceptions_inline("./smc_xslt/exceptions.xslt")] wssql
+ESPservice [version("3.06"), default_client_version("3.06"), auth_feature("DEFERRED"), exceptions_inline("./smc_xslt/exceptions.xslt")] wssql
 {
     ESPmethod [min_ver("3.03")] CreateTableAndLoad(CreateTableAndLoadRequest, CreateTableAndLoadResponse);
     ESPmethod [min_ver("3.02")] SetRelatedIndexes(SetRelatedIndexesRequest, SetRelatedIndexesResponse);

+ 9 - 6
esp/services/ws_sql/SQL2ECL/HPCCFileCache.cpp

@@ -44,7 +44,7 @@ void populateColums(IArrayOf<HPCCColumnMetaData> * cols, IArrayOf<IEspHPCCColumn
     }
 }
 
-bool HPCCFileCache::populateTablesResponse(IEspGetDBMetaDataResponse & tablesrespstruct, const char * filterby)
+bool HPCCFileCache::populateTablesResponse(IEspGetDBMetaDataResponse & tablesrespstruct, const char * filterby, bool nestedcolumns=true)
 {
     bool success = false;
 
@@ -80,12 +80,15 @@ bool HPCCFileCache::populateTablesResponse(IEspGetDBMetaDataResponse & tablesres
                    Owned<IEspHPCCColumn> pCol = createHPCCColumn();
                    HPCCColumnMetaData& currcol = cols->item(i);
 
-                   IArrayOf<HPCCColumnMetaData> * ccols = currcol.getChildColumns();
-                   if (ccols->length() != 0)
+                   if (nestedcolumns)
                    {
-                       IArrayOf<IEspHPCCColumn> pCColumns;
-                       populateColums(ccols, pCColumns);
-                       pCol->setColumns(pCColumns);
+                       IArrayOf<HPCCColumnMetaData> * ccols = currcol.getChildColumns();
+                       if (ccols->length() != 0)
+                       {
+                           IArrayOf<IEspHPCCColumn> pCColumns;
+                           populateColums(ccols, pCColumns);
+                           pCol->setColumns(pCColumns);
+                       }
                    }
                    pCol->setName(currcol.getColumnName());
                    pCol->setType(currcol.getColumnType());

+ 1 - 1
esp/services/ws_sql/SQL2ECL/HPCCFileCache.hpp

@@ -44,7 +44,7 @@ public:
     const char * cacheHpccFileByName(const char * filename, bool namevalidated = false);
     bool isHpccFileCached(const char * filename);
     HPCCFilePtr getHpccFileByName(const char * filename);
-    bool populateTablesResponse(IEspGetDBMetaDataResponse & tablesrespstruct, const char * filterby);
+    bool populateTablesResponse(IEspGetDBMetaDataResponse & tablesrespstruct, const char * filterby, bool nestedcolumns);
 
     HPCCFileCache(const char * username, const char * passwd)
     {

+ 18 - 6
esp/services/ws_sql/SQL2ECL/HPCCSQLTreeWalker.cpp

@@ -304,12 +304,20 @@ ISQLExpression * HPCCSQLTreeWalker::expressionTreeWalker(pANTLR3_BASE_TREE exprA
             case LIKE_SYM:
             case NOT_LIKE:
                 leftexp.set(expressionTreeWalker((pANTLR3_BASE_TREE)(exprAST->getChild(exprAST, 0)),exprAST));
-                if (leftexp->getExpType() != Value_ExpressionType && strnicmp(leftexp->getECLType(),"DATASET",7)==0)
-                    throw MakeStringException(-1, "Cannot apply arithmetic logic to normalized nested column: '%s'!\n", leftexp->getName());
+                if (leftexp->getLogicType() == NestedDS_LogicType)
+                {
+                    StringBuffer invalidexp;
+                    leftexp->toString(invalidexp, false);
+                    throw makeStringExceptionV(-1, "Cannot apply arithmetic logic to normalized nested column: '%s'!\n", invalidexp.str());
+                }
 
                 rightexp.set(expressionTreeWalker((pANTLR3_BASE_TREE)(exprAST->getChild(exprAST, 1)),exprAST));
-                if (rightexp->getExpType() != Value_ExpressionType && strnicmp(rightexp->getECLType(),"DATASET",7)==0)
-                    throw MakeStringException(-1, "Cannot apply arithmetic logic to normalized nested column: '%s'!\n", rightexp->getName());
+                if (rightexp->getLogicType() == NestedDS_LogicType)
+                {
+                    StringBuffer invalidexp;
+                    rightexp->toString(invalidexp, false);
+                    throw makeStringExceptionV(-1, "Cannot apply arithmetic logic to normalized nested column: '%s'!\n", invalidexp.str());
+                }
 
                 tmpexp.setown( new SQLBinaryExpression(exptype,leftexp, rightexp));
                 if (parameterizeStaticValues)
@@ -341,8 +349,12 @@ ISQLExpression * HPCCSQLTreeWalker::expressionTreeWalker(pANTLR3_BASE_TREE exprA
             case NOT_SYM:
             {
                 tmpexp.setown(new SQLUnaryExpression(expressionTreeWalker((pANTLR3_BASE_TREE)(exprAST->getChild(exprAST, 0)),exprAST), exptype ));
-                if (tmpexp->getExpType() != Value_ExpressionType && strnicmp(tmpexp->getECLType(),"DATASET",7)==0)
-                    throw MakeStringException(-1, "Cannot apply arithmetic logic to normalized nested column: '%s'!\n", rightexp->getName());
+                if (tmpexp->getLogicType() == NestedDS_LogicType)
+                {
+                    StringBuffer expstr;
+                    tmpexp->toString(expstr, false);
+                    throw makeStringExceptionV(-1, "Cannot apply arithmetic logic to normalized nested column: '%s'!\n", expstr.str());
+                }
                 break;
             }
             //case PARENEXP: ANTLR idiosyncrasy prevented using imaginary token as root node

+ 1 - 1
esp/services/ws_sql/ws_sqlService.cpp

@@ -53,7 +53,7 @@ bool CwssqlEx::onGetDBMetaData(IEspContext &context, IEspGetDBMetaDataRequest &r
     if (includetables)
     {
         Owned<HPCCFileCache> tmpHPCCFileCache = HPCCFileCache::createFileCache(username.str(), passwd);
-        tmpHPCCFileCache->populateTablesResponse(resp, req.getTableFilter());
+        tmpHPCCFileCache->populateTablesResponse(resp, req.getTableFilter(), context.getClientVersion() >= 3.06);
         resp.setTableCount(resp.getTables().length());
     }