test_class.file: herd-code/herd-service/src/test/java/org/finra/herd/service/helper/Hive13DdlGeneratorTest.java
test_class.identifier: Hive13DdlGeneratorTest
test_class.superclass: extends AbstractServiceTest
test_case.body: @Test
      public void testGenerateReplaceColumnsStatement()
      {
          BusinessObjectFormatDdlRequest businessObjectFormatDdlRequest = new BusinessObjectFormatDdlRequest();
          businessObjectFormatDdlRequest.setTableName(TABLE_NAME);
          BusinessObjectFormatEntity businessObjectFormatEntity = businessObjectFormatDaoTestHelper
              .createBusinessObjectFormatEntity(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, FORMAT_DESCRIPTION,
                  FORMAT_DOCUMENT_SCHEMA, FORMAT_DOCUMENT_SCHEMA_URL, true, PARTITION_KEY);
          {
              SchemaColumnEntity schemaColumnEntity = new SchemaColumnEntity();
              schemaColumnEntity.setPosition(0);
              schemaColumnEntity.setName("col1");
              schemaColumnEntity.setType("varchar");
              schemaColumnEntity.setSize("255");
              schemaColumnEntity.setDescription("lorem ipsum");
              businessObjectFormatEntity.getSchemaColumns().add(schemaColumnEntity);
          }
          {
              SchemaColumnEntity schemaColumnEntity = new SchemaColumnEntity();
              schemaColumnEntity.setPosition(1);
              schemaColumnEntity.setName("col2");
              schemaColumnEntity.setType("date");
              businessObjectFormatEntity.getSchemaColumns().add(schemaColumnEntity);
          }
          {
              SchemaColumnEntity schemaColumnEntity = new SchemaColumnEntity();
              schemaColumnEntity.setPosition(2);
              schemaColumnEntity.setName("col3");
              // Use complex schema data type with whitespaces in it.
              // Expect the whitespaces to be removed whilke validating the complex data types.
              schemaColumnEntity.setType("map <double, array<bigint(5)>>");
              businessObjectFormatEntity.getSchemaColumns().add(schemaColumnEntity);
          }
          {
              SchemaColumnEntity schemaColumnEntity = new SchemaColumnEntity();
              schemaColumnEntity.setPosition(3);
              schemaColumnEntity.setName("col4");
              schemaColumnEntity.setType("uniontype<int,double,array<string>,struct<a:int,b:string>>");
              businessObjectFormatEntity.getSchemaColumns().add(schemaColumnEntity);
          }
          {
              SchemaColumnEntity schemaColumnEntity = new SchemaColumnEntity();
              schemaColumnEntity.setPosition(3);
              schemaColumnEntity.setName("col4");
              schemaColumnEntity.setType("struct<s:string,f:float,m:map<double,array<bigint>>>");
              businessObjectFormatEntity.getSchemaColumns().add(schemaColumnEntity);
          }
          String actual = hive13DdlGenerator.generateReplaceColumnsStatement(businessObjectFormatDdlRequest, businessObjectFormatEntity);
  
          String expected =
              "ALTER TABLE `" + businessObjectFormatDdlRequest.getTableName() + "` REPLACE COLUMNS (\n" + "    `col1` VARCHAR(255) COMMENT 'lorem ipsum',\n" +
                  "    `col2` DATE,\n" + "    `col3` map<double,array<bigint(5)>>,\n" +
                  "    `col4` uniontype<int,double,array<string>,struct<a:int,b:string>>,\n" +
                  "    `col4` struct<s:string,f:float,m:map<double,array<bigint>>>);";
  
          Assert.assertEquals("generated DDL", expected, actual);
      }
test_case.class_method_signature: Hive13DdlGeneratorTest.testGenerateReplaceColumnsStatement()
test_case.full_signature: @Test public void testGenerateReplaceColumnsStatement()
test_case.identifier: testGenerateReplaceColumnsStatement
test_case.invocations: setTableName createBusinessObjectFormatEntity setPosition setName setType setSize setDescription add getSchemaColumns setPosition setName setType add getSchemaColumns setPosition setName setType add getSchemaColumns setPosition setName setType add getSchemaColumns setPosition setName setType add getSchemaColumns generateReplaceColumnsStatement getTableName assertEquals
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testGenerateReplaceColumnsStatement()
focal_class.declarator: NO_PARTITIONING_PARTITION_KEY = "partition"
focal_class.modifier: public static final
focal_class.original_string: public static final String NO_PARTITIONING_PARTITION_KEY = "partition";
focal_class.type: String
focal_class.var_name: NO_PARTITIONING_PARTITION_KEY
focal_class.declarator: NO_PARTITIONING_PARTITION_VALUE = "none"
focal_class.modifier: public static final
focal_class.original_string: public static final String NO_PARTITIONING_PARTITION_VALUE = "none";
focal_class.type: String
focal_class.var_name: NO_PARTITIONING_PARTITION_VALUE
focal_class.declarator: ORC_HIVE_FILE_FORMAT = "ORC"
focal_class.modifier: public static final
focal_class.original_string: public static final String ORC_HIVE_FILE_FORMAT = "ORC";
focal_class.type: String
focal_class.var_name: ORC_HIVE_FILE_FORMAT
focal_class.declarator: PARQUET_HIVE_FILE_FORMAT = "PARQUET"
focal_class.modifier: public static final
focal_class.original_string: public static final String PARQUET_HIVE_FILE_FORMAT = "PARQUET";
focal_class.type: String
focal_class.var_name: PARQUET_HIVE_FILE_FORMAT
focal_class.declarator: TEXT_HIVE_FILE_FORMAT = "TEXTFILE"
focal_class.modifier: public static final
focal_class.original_string: public static final String TEXT_HIVE_FILE_FORMAT = "TEXTFILE";
focal_class.type: String
focal_class.var_name: TEXT_HIVE_FILE_FORMAT
focal_class.declarator: JSON_HIVE_FILE_FORMAT = "JSONFILE"
focal_class.modifier: public static final
focal_class.original_string: public static final String JSON_HIVE_FILE_FORMAT = "JSONFILE";
focal_class.type: String
focal_class.var_name: JSON_HIVE_FILE_FORMAT
focal_class.declarator: REGEX_S3_EMPTY_PARTITION = "_\\$folder\\$"
focal_class.modifier: public static final
focal_class.original_string: public static final String REGEX_S3_EMPTY_PARTITION = "_\\$folder\\$";
focal_class.type: String
focal_class.var_name: REGEX_S3_EMPTY_PARTITION
focal_class.declarator: HIVE_COMPLEX_DATA_TYPES =
          Arrays.asList(Category.LIST.toString(), Category.MAP.toString(), Category.UNION.toString(), Category.STRUCT.toString())
focal_class.modifier: private static final
focal_class.original_string: private static final List<String> HIVE_COMPLEX_DATA_TYPES =
          Arrays.asList(Category.LIST.toString(), Category.MAP.toString(), Category.UNION.toString(), Category.STRUCT.toString());
focal_class.type: List<String>
focal_class.var_name: HIVE_COMPLEX_DATA_TYPES
focal_class.declarator: businessObjectDataDdlPartitionsHelper
focal_class.modifier: @Autowired
      private
focal_class.original_string: @Autowired
      private BusinessObjectDataDdlPartitionsHelper businessObjectDataDdlPartitionsHelper;
focal_class.type: BusinessObjectDataDdlPartitionsHelper
focal_class.var_name: businessObjectDataDdlPartitionsHelper
focal_class.declarator: businessObjectDataHelper
focal_class.modifier: @Autowired
      private
focal_class.original_string: @Autowired
      private BusinessObjectDataHelper businessObjectDataHelper;
focal_class.type: BusinessObjectDataHelper
focal_class.var_name: businessObjectDataHelper
focal_class.declarator: businessObjectFormatHelper
focal_class.modifier: @Autowired
      private
focal_class.original_string: @Autowired
      private BusinessObjectFormatHelper businessObjectFormatHelper;
focal_class.type: BusinessObjectFormatHelper
focal_class.var_name: businessObjectFormatHelper
focal_class.file: herd-code/herd-service/src/main/java/org/finra/herd/service/helper/Hive13DdlGenerator.java
focal_class.identifier: Hive13DdlGenerator
focal_class.class_method_signature: Hive13DdlGenerator.escapeSingleQuotes(String string)
focal_class.full_signature: public String escapeSingleQuotes(String string)
focal_class.identifier: escapeSingleQuotes
focal_class.modifiers: public
focal_class.parameters: (String string)
focal_class.return: String
focal_class.signature: String escapeSingleQuotes(String string)
focal_class.class_method_signature: Hive13DdlGenerator.generateCreateTableDdl(BusinessObjectDataDdlRequest request, BusinessObjectFormatEntity businessObjectFormatEntity,
          CustomDdlEntity customDdlEntity, List<String> storageNames, List<StorageEntity> requestedStorageEntities,
          Map<String, StorageEntity> cachedStorageEntities, Map<String, String> cachedS3BucketNames)
focal_class.full_signature: @Override public String generateCreateTableDdl(BusinessObjectDataDdlRequest request, BusinessObjectFormatEntity businessObjectFormatEntity,
          CustomDdlEntity customDdlEntity, List<String> storageNames, List<StorageEntity> requestedStorageEntities,
          Map<String, StorageEntity> cachedStorageEntities, Map<String, String> cachedS3BucketNames)
focal_class.identifier: generateCreateTableDdl
focal_class.modifiers: @Override public
focal_class.parameters: (BusinessObjectDataDdlRequest request, BusinessObjectFormatEntity businessObjectFormatEntity,
          CustomDdlEntity customDdlEntity, List<String> storageNames, List<StorageEntity> requestedStorageEntities,
          Map<String, StorageEntity> cachedStorageEntities, Map<String, String> cachedS3BucketNames)
focal_class.return: String
focal_class.signature: String generateCreateTableDdl(BusinessObjectDataDdlRequest request, BusinessObjectFormatEntity businessObjectFormatEntity,
          CustomDdlEntity customDdlEntity, List<String> storageNames, List<StorageEntity> requestedStorageEntities,
          Map<String, StorageEntity> cachedStorageEntities, Map<String, String> cachedS3BucketNames)
focal_class.class_method_signature: Hive13DdlGenerator.generateCreateTableDdl(BusinessObjectFormatDdlRequest request, BusinessObjectFormatEntity businessObjectFormatEntity,
          CustomDdlEntity customDdlEntity)
focal_class.full_signature: @Override public String generateCreateTableDdl(BusinessObjectFormatDdlRequest request, BusinessObjectFormatEntity businessObjectFormatEntity,
          CustomDdlEntity customDdlEntity)
focal_class.identifier: generateCreateTableDdl
focal_class.modifiers: @Override public
focal_class.parameters: (BusinessObjectFormatDdlRequest request, BusinessObjectFormatEntity businessObjectFormatEntity,
          CustomDdlEntity customDdlEntity)
focal_class.return: String
focal_class.signature: String generateCreateTableDdl(BusinessObjectFormatDdlRequest request, BusinessObjectFormatEntity businessObjectFormatEntity,
          CustomDdlEntity customDdlEntity)
focal_class.class_method_signature: Hive13DdlGenerator.generateReplaceColumnsStatement(BusinessObjectFormatDdlRequest request, BusinessObjectFormatEntity businessObjectFormatEntity)
focal_class.full_signature: @Override public String generateReplaceColumnsStatement(BusinessObjectFormatDdlRequest request, BusinessObjectFormatEntity businessObjectFormatEntity)
focal_class.identifier: generateReplaceColumnsStatement
focal_class.modifiers: @Override public
focal_class.parameters: (BusinessObjectFormatDdlRequest request, BusinessObjectFormatEntity businessObjectFormatEntity)
focal_class.return: String
focal_class.signature: String generateReplaceColumnsStatement(BusinessObjectFormatDdlRequest request, BusinessObjectFormatEntity businessObjectFormatEntity)
focal_class.class_method_signature: Hive13DdlGenerator.getDdlCharacterValue(String string)
focal_class.full_signature: public String getDdlCharacterValue(String string)
focal_class.identifier: getDdlCharacterValue
focal_class.modifiers: public
focal_class.parameters: (String string)
focal_class.return: String
focal_class.signature: String getDdlCharacterValue(String string)
focal_class.class_method_signature: Hive13DdlGenerator.getDdlCharacterValue(String string, boolean escapeSingleBackslash)
focal_class.full_signature: public String getDdlCharacterValue(String string, boolean escapeSingleBackslash)
focal_class.identifier: getDdlCharacterValue
focal_class.modifiers: public
focal_class.parameters: (String string, boolean escapeSingleBackslash)
focal_class.return: String
focal_class.signature: String getDdlCharacterValue(String string, boolean escapeSingleBackslash)
focal_class.class_method_signature: Hive13DdlGenerator.getDdlOutputFormat()
focal_class.full_signature: @Override public BusinessObjectDataDdlOutputFormatEnum getDdlOutputFormat()
focal_class.identifier: getDdlOutputFormat
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: BusinessObjectDataDdlOutputFormatEnum
focal_class.signature: BusinessObjectDataDdlOutputFormatEnum getDdlOutputFormat()
focal_class.class_method_signature: Hive13DdlGenerator.getHivePartitions(BusinessObjectDataKey businessObjectDataKey, List<SchemaColumn> autoDiscoverableSubPartitionColumns,
          String s3KeyPrefix, Collection<String> storageFiles, String storageName)
focal_class.full_signature: public List<HivePartitionDto> getHivePartitions(BusinessObjectDataKey businessObjectDataKey, List<SchemaColumn> autoDiscoverableSubPartitionColumns,
          String s3KeyPrefix, Collection<String> storageFiles, String storageName)
focal_class.identifier: getHivePartitions
focal_class.modifiers: public
focal_class.parameters: (BusinessObjectDataKey businessObjectDataKey, List<SchemaColumn> autoDiscoverableSubPartitionColumns,
          String s3KeyPrefix, Collection<String> storageFiles, String storageName)
focal_class.return: List<HivePartitionDto>
focal_class.signature: List<HivePartitionDto> getHivePartitions(BusinessObjectDataKey businessObjectDataKey, List<SchemaColumn> autoDiscoverableSubPartitionColumns,
          String s3KeyPrefix, Collection<String> storageFiles, String storageName)
focal_class.class_method_signature: Hive13DdlGenerator.getHivePathPattern(List<SchemaColumn> partitionColumns)
focal_class.full_signature: public Pattern getHivePathPattern(List<SchemaColumn> partitionColumns)
focal_class.identifier: getHivePathPattern
focal_class.modifiers: public
focal_class.parameters: (List<SchemaColumn> partitionColumns)
focal_class.return: Pattern
focal_class.signature: Pattern getHivePathPattern(List<SchemaColumn> partitionColumns)
focal_class.class_method_signature: Hive13DdlGenerator.getHivePathRegex(List<SchemaColumn> partitionColumns)
focal_class.full_signature: public String getHivePathRegex(List<SchemaColumn> partitionColumns)
focal_class.identifier: getHivePathRegex
focal_class.modifiers: public
focal_class.parameters: (List<SchemaColumn> partitionColumns)
focal_class.return: String
focal_class.signature: String getHivePathRegex(List<SchemaColumn> partitionColumns)
focal_class.class_method_signature: Hive13DdlGenerator.assertSchemaColumnsNotEmpty(BusinessObjectFormat businessObjectFormat, BusinessObjectFormatEntity businessObjectFormatEntity)
focal_class.full_signature: private void assertSchemaColumnsNotEmpty(BusinessObjectFormat businessObjectFormat, BusinessObjectFormatEntity businessObjectFormatEntity)
focal_class.identifier: assertSchemaColumnsNotEmpty
focal_class.modifiers: private
focal_class.parameters: (BusinessObjectFormat businessObjectFormat, BusinessObjectFormatEntity businessObjectFormatEntity)
focal_class.return: void
focal_class.signature: void assertSchemaColumnsNotEmpty(BusinessObjectFormat businessObjectFormat, BusinessObjectFormatEntity businessObjectFormatEntity)
focal_class.class_method_signature: Hive13DdlGenerator.generateCreateTableDdlHelper(BusinessObjectDataDdlPartitionsHelper.GenerateDdlRequestWrapper generateDdlRequest)
focal_class.full_signature: private String generateCreateTableDdlHelper(BusinessObjectDataDdlPartitionsHelper.GenerateDdlRequestWrapper generateDdlRequest)
focal_class.identifier: generateCreateTableDdlHelper
focal_class.modifiers: private
focal_class.parameters: (BusinessObjectDataDdlPartitionsHelper.GenerateDdlRequestWrapper generateDdlRequest)
focal_class.return: String
focal_class.signature: String generateCreateTableDdlHelper(BusinessObjectDataDdlPartitionsHelper.GenerateDdlRequestWrapper generateDdlRequest)
focal_class.class_method_signature: Hive13DdlGenerator.generateDdlColumns(BusinessObjectFormatEntity businessObjectFormatEntity, BusinessObjectFormat businessObjectFormat)
focal_class.full_signature: private String generateDdlColumns(BusinessObjectFormatEntity businessObjectFormatEntity, BusinessObjectFormat businessObjectFormat)
focal_class.identifier: generateDdlColumns
focal_class.modifiers: private
focal_class.parameters: (BusinessObjectFormatEntity businessObjectFormatEntity, BusinessObjectFormat businessObjectFormat)
focal_class.return: String
focal_class.signature: String generateDdlColumns(BusinessObjectFormatEntity businessObjectFormatEntity, BusinessObjectFormat businessObjectFormat)
focal_class.class_method_signature: Hive13DdlGenerator.generateStandardBaseDdl(BusinessObjectDataDdlPartitionsHelper.GenerateDdlRequestWrapper generateDdlRequest, StringBuilder sb,
          BusinessObjectFormat businessObjectFormat, String ifNotExistsOption)
focal_class.full_signature: private void generateStandardBaseDdl(BusinessObjectDataDdlPartitionsHelper.GenerateDdlRequestWrapper generateDdlRequest, StringBuilder sb,
          BusinessObjectFormat businessObjectFormat, String ifNotExistsOption)
focal_class.identifier: generateStandardBaseDdl
focal_class.modifiers: private
focal_class.parameters: (BusinessObjectDataDdlPartitionsHelper.GenerateDdlRequestWrapper generateDdlRequest, StringBuilder sb,
          BusinessObjectFormat businessObjectFormat, String ifNotExistsOption)
focal_class.return: void
focal_class.signature: void generateStandardBaseDdl(BusinessObjectDataDdlPartitionsHelper.GenerateDdlRequestWrapper generateDdlRequest, StringBuilder sb,
          BusinessObjectFormat businessObjectFormat, String ifNotExistsOption)
focal_class.class_method_signature: Hive13DdlGenerator.getHiveDataType(SchemaColumn schemaColumn, BusinessObjectFormatEntity businessObjectFormatEntity)
focal_class.full_signature: private String getHiveDataType(SchemaColumn schemaColumn, BusinessObjectFormatEntity businessObjectFormatEntity)
focal_class.identifier: getHiveDataType
focal_class.modifiers: private
focal_class.parameters: (SchemaColumn schemaColumn, BusinessObjectFormatEntity businessObjectFormatEntity)
focal_class.return: String
focal_class.signature: String getHiveDataType(SchemaColumn schemaColumn, BusinessObjectFormatEntity businessObjectFormatEntity)
focal_class.class_method_signature: Hive13DdlGenerator.isHiveComplexDataType(String inputString)
focal_class.full_signature: private boolean isHiveComplexDataType(String inputString)
focal_class.identifier: isHiveComplexDataType
focal_class.modifiers: private
focal_class.parameters: (String inputString)
focal_class.return: boolean
focal_class.signature: boolean isHiveComplexDataType(String inputString)
focal_class.class_method_signature: Hive13DdlGenerator.getHiveFileFormat(BusinessObjectFormatEntity businessObjectFormatEntity)
focal_class.full_signature: private String getHiveFileFormat(BusinessObjectFormatEntity businessObjectFormatEntity)
focal_class.identifier: getHiveFileFormat
focal_class.modifiers: private
focal_class.parameters: (BusinessObjectFormatEntity businessObjectFormatEntity)
focal_class.return: String
focal_class.signature: String getHiveFileFormat(BusinessObjectFormatEntity businessObjectFormatEntity)
focal_class.class_method_signature: Hive13DdlGenerator.processPartitionFiltersForGenerateDdl(BusinessObjectDataDdlPartitionsHelper.GenerateDdlRequestWrapper generateDdlRequest, StringBuilder sb,
          HashMap<String, String> replacements, BusinessObjectFormat businessObjectFormat, String ifNotExistsOption)
focal_class.full_signature: private void processPartitionFiltersForGenerateDdl(BusinessObjectDataDdlPartitionsHelper.GenerateDdlRequestWrapper generateDdlRequest, StringBuilder sb,
          HashMap<String, String> replacements, BusinessObjectFormat businessObjectFormat, String ifNotExistsOption)
focal_class.identifier: processPartitionFiltersForGenerateDdl
focal_class.modifiers: private
focal_class.parameters: (BusinessObjectDataDdlPartitionsHelper.GenerateDdlRequestWrapper generateDdlRequest, StringBuilder sb,
          HashMap<String, String> replacements, BusinessObjectFormat businessObjectFormat, String ifNotExistsOption)
focal_class.return: void
focal_class.signature: void processPartitionFiltersForGenerateDdl(BusinessObjectDataDdlPartitionsHelper.GenerateDdlRequestWrapper generateDdlRequest, StringBuilder sb,
          HashMap<String, String> replacements, BusinessObjectFormat businessObjectFormat, String ifNotExistsOption)
focal_class.superclass: extends DdlGenerator
focal_method.body: @Override
      public String generateReplaceColumnsStatement(BusinessObjectFormatDdlRequest request, BusinessObjectFormatEntity businessObjectFormatEntity)
      {
          BusinessObjectFormat businessObjectFormat = businessObjectFormatHelper.createBusinessObjectFormatFromEntity(businessObjectFormatEntity);
  
          assertSchemaColumnsNotEmpty(businessObjectFormat, businessObjectFormatEntity);
  
          StringBuilder builder = new StringBuilder(34);
          builder.append("ALTER TABLE `");
          builder.append(request.getTableName());
          builder.append("` REPLACE COLUMNS (\n");
          builder.append(generateDdlColumns(businessObjectFormatEntity, businessObjectFormat));
          return builder.toString().trim() + ';';
      }
focal_method.class_method_signature: Hive13DdlGenerator.generateReplaceColumnsStatement(BusinessObjectFormatDdlRequest request, BusinessObjectFormatEntity businessObjectFormatEntity)
focal_method.full_signature: @Override public String generateReplaceColumnsStatement(BusinessObjectFormatDdlRequest request, BusinessObjectFormatEntity businessObjectFormatEntity)
focal_method.identifier: generateReplaceColumnsStatement
focal_method.invocations: createBusinessObjectFormatFromEntity assertSchemaColumnsNotEmpty append append getTableName append append generateDdlColumns trim toString
focal_method.modifiers: @Override public
focal_method.parameters: (BusinessObjectFormatDdlRequest request, BusinessObjectFormatEntity businessObjectFormatEntity)
focal_method.return: String
focal_method.signature: String generateReplaceColumnsStatement(BusinessObjectFormatDdlRequest request, BusinessObjectFormatEntity businessObjectFormatEntity)