Program: 6789
Project: 6789
Buggy source:
/** 
 * Enable ad-hoc exploration on the given dataset by creating a corresponding Hive table. If exploration has already been enabled on the dataset, this will be a no-op. Assumes the dataset actually exists.
 * @param datasetID the ID of the dataset to enable
 * @param spec the specification for the dataset to enable
 * @return query handle for creating the Hive table for the dataset
 * @throws IllegalArgumentException if some required dataset property like schema is not set
 * @throws UnsupportedTypeException if the schema of the dataset is not compatible with Hive
 * @throws ExploreException if there was an exception submitting the create table statement
 * @throws SQLException if there was a problem with the create table statement
 * @throws DatasetNotFoundException if the dataset had to be instantiated, but could not be found
 * @throws ClassNotFoundException if the was a missing class when instantiating the dataset
 */
public QueryHandle enableDataset(Id.DatasetInstance datasetID,DatasetSpecification spec) throws IllegalArgumentException, ExploreException, SQLException, UnsupportedTypeException, DatasetNotFoundException, ClassNotFoundException {
  String datasetName=datasetID.getId();
  Map<String,String> serdeProperties=ImmutableMap.of(Constants.Explore.DATASET_NAME,datasetName,Constants.Explore.DATASET_NAMESPACE,datasetID.getNamespaceId());
  String createStatement=null;
  String datasetType=spec.getType();
  if (ObjectMappedTableModule.FULL_NAME.equals(datasetType) || ObjectMappedTableModule.SHORT_NAME.equals(datasetType)) {
    return createFromSchemaProperty(spec,datasetID,serdeProperties);
  }
  try (SystemDatasetInstantiator datasetInstantiator=datasetInstantiatorFactory.create()){
    Dataset dataset=datasetInstantiator.getDataset(datasetID);
    if (dataset == null) {
      throw new DatasetNotFoundException(datasetID);
    }
    if (dataset instanceof Table) {
      return createFromSchemaProperty(spec,datasetID,serdeProperties);
    }
    boolean isRecordScannable=dataset instanceof RecordScannable;
    boolean isRecordWritable=dataset instanceof RecordWritable;
    if (isRecordScannable || isRecordWritable) {
      Type recordType=isRecordScannable ? ((RecordScannable)dataset).getRecordType() : ((RecordWritable)dataset).getRecordType();
      if (StructuredRecord.class.equals(recordType)) {
        if (isRecordWritable && !isRecordScannable) {
          throw new UnsupportedTypeException("String_Node_Str");
        }
        return createFromSchemaProperty(spec,datasetID,serdeProperties);
      }
      LOG.debug("String_Node_Str",datasetName);
      createStatement=new CreateStatementBuilder(datasetName,getDatasetTableName(datasetID)).setSchema(hiveSchemaFor(recordType)).setTableComment("String_Node_Str").buildWithStorageHandler(Constants.Explore.DATASET_STORAGE_HANDLER_CLASS,serdeProperties);
    }
 else     if (dataset instanceof FileSet || dataset instanceof PartitionedFileSet) {
      Map<String,String> properties=spec.getProperties();
      if (FileSetProperties.isExploreEnabled(properties)) {
        LOG.debug("String_Node_Str",datasetName);
        createStatement=generateFileSetCreateStatement(datasetID,dataset,properties);
      }
    }
  }
 catch (  IOException e) {
    LOG.error("String_Node_Str",datasetID,e);
    throw new ExploreException("String_Node_Str" + datasetID);
  }
  if (createStatement != null) {
    return exploreService.execute(datasetID.getNamespace(),createStatement);
  }
 else {
    return QueryHandle.NO_OP;
  }
}

Fixed version (ground truth):
/** 
 * Enable ad-hoc exploration on the given dataset by creating a corresponding Hive table. If exploration has already been enabled on the dataset, this will be a no-op. Assumes the dataset actually exists.
 * @param datasetID the ID of the dataset to enable
 * @param spec the specification for the dataset to enable
 * @return query handle for creating the Hive table for the dataset
 * @throws IllegalArgumentException if some required dataset property like schema is not set
 * @throws UnsupportedTypeException if the schema of the dataset is not compatible with Hive
 * @throws ExploreException if there was an exception submitting the create table statement
 * @throws SQLException if there was a problem with the create table statement
 * @throws DatasetNotFoundException if the dataset had to be instantiated, but could not be found
 * @throws ClassNotFoundException if the was a missing class when instantiating the dataset
 */
public QueryHandle enableDataset(Id.DatasetInstance datasetID,DatasetSpecification spec) throws IllegalArgumentException, ExploreException, SQLException, UnsupportedTypeException, DatasetNotFoundException, ClassNotFoundException {
  String datasetName=datasetID.getId();
  Map<String,String> serdeProperties=ImmutableMap.of(Constants.Explore.DATASET_NAME,datasetName,Constants.Explore.DATASET_NAMESPACE,datasetID.getNamespaceId());
  String createStatement=null;
  String datasetType=spec.getType();
  if (ObjectMappedTableModule.FULL_NAME.equals(datasetType) || ObjectMappedTableModule.SHORT_NAME.equals(datasetType)) {
    return createFromSchemaProperty(spec,datasetID,serdeProperties,true);
  }
  try (SystemDatasetInstantiator datasetInstantiator=datasetInstantiatorFactory.create()){
    Dataset dataset=datasetInstantiator.getDataset(datasetID);
    if (dataset == null) {
      throw new DatasetNotFoundException(datasetID);
    }
    if (dataset instanceof Table) {
      return createFromSchemaProperty(spec,datasetID,serdeProperties,false);
    }
    boolean isRecordScannable=dataset instanceof RecordScannable;
    boolean isRecordWritable=dataset instanceof RecordWritable;
    if (isRecordScannable || isRecordWritable) {
      Type recordType=isRecordScannable ? ((RecordScannable)dataset).getRecordType() : ((RecordWritable)dataset).getRecordType();
      if (StructuredRecord.class.equals(recordType)) {
        if (isRecordWritable && !isRecordScannable) {
          throw new UnsupportedTypeException("String_Node_Str");
        }
        return createFromSchemaProperty(spec,datasetID,serdeProperties,true);
      }
      LOG.debug("String_Node_Str",datasetName);
      createStatement=new CreateStatementBuilder(datasetName,getDatasetTableName(datasetID)).setSchema(hiveSchemaFor(recordType)).setTableComment("String_Node_Str").buildWithStorageHandler(Constants.Explore.DATASET_STORAGE_HANDLER_CLASS,serdeProperties);
    }
 else     if (dataset instanceof FileSet || dataset instanceof PartitionedFileSet) {
      Map<String,String> properties=spec.getProperties();
      if (FileSetProperties.isExploreEnabled(properties)) {
        LOG.debug("String_Node_Str",datasetName);
        createStatement=generateFileSetCreateStatement(datasetID,dataset,properties);
      }
    }
  }
 catch (  IOException e) {
    LOG.error("String_Node_Str",datasetID,e);
    throw new ExploreException("String_Node_Str" + datasetID);
  }
  if (createStatement != null) {
    return exploreService.execute(datasetID.getNamespace(),createStatement);
  }
 else {
    return QueryHandle.NO_OP;
  }
}