Github user robertamarton commented on a diff in the pull request:

    https://github.com/apache/incubator-trafodion/pull/74#discussion_r38960453
  
    --- Diff: core/sql/common/ComMisc.cpp ---
    @@ -99,17 +100,74 @@ NABoolean ComIsTrafodionReservedSchemaName(
       return FALSE;
     }
     
    -// schema names of pattern "_HV ... _" and "_HB_ ... _" are reserved to 
store
    +// schema names of pattern "_HV_ ... _" and "_HB_ ... _" are reserved to 
store
     // external hive and hbase tables
     NABoolean ComIsTrafodionExternalSchemaName (
                                         const NAString &schName)
     {
       Int32 len (schName.length());
    +
    +  // check for HIVE
       Int32 prefixLen = sizeof(HIVE_EXT_SCHEMA_PREFIX);
       if (len > prefixLen && 
    -      (schName(0,prefixLen-1) == HIVE_EXT_SCHEMA_PREFIX || 
    -       schName(0,prefixLen-1) == HBASE_EXT_SCHEMA_PREFIX) && 
    -      schName(len-1) == '_' )
    +     (schName(0,prefixLen-1) == HIVE_EXT_SCHEMA_PREFIX && 
    +      schName(len-1) == '_' ))
         return TRUE;
    +
    +  // check for HBASE
    +  prefixLen = sizeof(HBASE_EXT_SCHEMA_PREFIX);
    +  if (len > prefixLen && 
    +     (schName(0,prefixLen-1) == HBASE_EXT_SCHEMA_PREFIX && 
    +      schName(len-1) == '_' ))
    +    return TRUE;
    +
       return FALSE;
     }
    +
    +// 
----------------------------------------------------------------------------
    +// function: ComConvertNativeNameToTrafName
    +//
    +// this fuction converts the native HIVE or HBASE object name into its
    +// Trafodion external name format.
    +//
    +// params:
    +//    catalogName - catalog name to identify HBASE or HIVE native table
    +//    schemaName - external name of the HBASE or HIVE schema
    +//    objectName - external name of the HBASE of HIVE table
    +//
    +// If it is not HIVE or HBASE, just return the qualified name
    +// 
----------------------------------------------------------------------------
    +NAString ComConvertNativeNameToTrafName ( 
    +  const NAString &catalogName,
    +  const NAString &schemaName,
    +  const NAString &objectName)
    +{
    +  // generate new schema name 
    +  NAString tempSchemaName; 
    +  if (catalogName == HIVE_SYSTEM_CATALOG)
    +    tempSchemaName += HIVE_EXT_SCHEMA_PREFIX;
    +  else if(catalogName == HBASE_SYSTEM_CATALOG)
    +    tempSchemaName += HBASE_EXT_SCHEMA_PREFIX;
    +  else
    +    return catalogName + NAString(".") +
    +           schemaName + NAString(".") +
    +           objectName; 
    +
    +  ComAnsiNamePart externalAnsiName(schemaName, 
ComAnsiNamePart::EXTERNAL_FORMAT);
    +  tempSchemaName += externalAnsiName.getInternalName();
    +  tempSchemaName.append ("_");
    +
    +  // Catalog name is "TRAFODION"
    +  NAString convertedName (CmpSeabaseDDL::getSystemCatalogStatic());
    +  convertedName += ".";
    +
    +  // append transformed schema name, convert internal name to external 
format
    +  ComAnsiNamePart internalAnsiName(tempSchemaName, 
ComAnsiNamePart::INTERNAL_FORMAT);
    +  convertedName += internalAnsiName.getExternalName();
    +
    +  // object  name is appended without change
    --- End diff --
    
    We require the names to be in external format before entering this method.  
I am using the ComAnsiNamePart class to convert from external to internal and 
back.  The constructor calls a method called "copyExternalName" which checks 
for a valid name.  However,  the constructor ignores the errors.  It looks like 
the method "isValid" should be called after constructing the object.  In this 
case, the name will be empty.  
    
    I did run tests with both delimited and non-delimited names so the code is 
working correctly today.  In the future, we should probably change this code.  
We should also look at other places where ComAnsiNamePart is called to make 
sure a similar issue does not exist.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to