nus-yam/ex-repair huggingface dataset:
Program: 111808
Project: 111808
Buggy source:
/** 
 * Returns a string which concisely describes the definition of this relational expression. Two relational expressions are equivalent if and only if their digests are the same. <p>The digest does not contain the relational expression's identity -- that would prevent similar relational expressions from ever comparing equal -- but does include the identity of children (on the assumption that children have already been normalized). <p>If you want a descriptive string which contains the identity, call  {@link Object#toString()}, which always returns "rel#{id}:{digest}".
 */
String getDigest();

Fixed version (ground truth):
/** 
 * Returns a string which concisely describes the definition of this relational expression. Two relational expressions are equivalent if and only if their digests are the same. <p>The digest does not contain the relational expression's identity -- that would prevent similar relational expressions from ever comparing equal -- but does include the identity of children (on the assumption that children have already been normalized). <p>If you want a descriptive string which contains the identity, call  {@link Object#toString()}, which always returns "rel#{id}:{digest}".
 * @return Digest of this {@code RelNode}
 */
String getDigest();
Program: 111809
Project: 111809
Buggy source:
List<? extends RelOptNode> getInputs();

Fixed version (ground truth):
/** 
 * Returns an array of this relational expression's inputs. If there are no inputs, returns an empty list, not   {@code null}.
 * @return Array of this relational expression's inputs
 */
List<? extends RelOptNode> getInputs();
Program: 111810
Project: 111810
Buggy source:
/** 
 * Returns a string which describes the relational expression and, unlike  {@link #getDigest()}, also includes the identity. Typically returns "rel#{id}:{digest}".
 */
String getDescription();

Fixed version (ground truth):
/** 
 * Returns a string which describes the relational expression and, unlike  {@link #getDigest()}, also includes the identity. Typically returns "rel#{id}:{digest}".
 * @return String which describes the relational expression and, unlike{@link #getDigest()}, also includes the identity
 */
String getDescription();
Program: 111811
Project: 111811
Buggy source:
/** 
 * Creates a list of child operands that matches child relational expressions in any order. <p>This is useful when matching a relational expression which can have a variable number of children. For example, the rule to eliminate empty children of a Union would have operands</p> <blockquote>Operand(Union, true, Operand(Empty))</blockquote> <p>and given the relational expressions</p> <blockquote>Union(LogicalFilter, Empty, LogicalProject)</blockquote> <p>would fire the rule with arguments</p> <blockquote>{Union, Empty}</blockquote> <p>It is up to the rule to deduce the other children, or indeed the position of the matched child.</p>
 * @param first First child operand
 * @param rest  Remaining child operands (may be empty)
 */
public static RelOptRuleOperandChildren unordered(RelOptRuleOperand first,RelOptRuleOperand... rest){
  return new RelOptRuleOperandChildren(RelOptRuleOperandChildPolicy.UNORDERED,ImmutableList.<RelOptRuleOperand>builder().add(first).add(rest).build());
}

Fixed version (ground truth):
/** 
 * Creates a list of child operands that matches child relational expressions in any order. <p>This is useful when matching a relational expression which can have a variable number of children. For example, the rule to eliminate empty children of a Union would have operands</p> <blockquote>Operand(Union, true, Operand(Empty))</blockquote> <p>and given the relational expressions</p> <blockquote>Union(LogicalFilter, Empty, LogicalProject)</blockquote> <p>would fire the rule with arguments</p> <blockquote>{Union, Empty}</blockquote> <p>It is up to the rule to deduce the other children, or indeed the position of the matched child.</p>
 * @param first First child operand
 * @param rest  Remaining child operands (may be empty)
 * @return List of child operands that matches child relationalexpressions in any order
 */
public static RelOptRuleOperandChildren unordered(RelOptRuleOperand first,RelOptRuleOperand... rest){
  return new RelOptRuleOperandChildren(RelOptRuleOperandChildPolicy.UNORDERED,ImmutableList.<RelOptRuleOperand>builder().add(first).add(rest).build());
}
Program: 111812
Project: 111812
Buggy source:
/** 
 * Creates a list of child operands that matches child relational expressions in the order they appear.
 * @param first First child operand
 * @param rest  Remaining child operands (may be empty)
 */
public static RelOptRuleOperandChildren some(RelOptRuleOperand first,RelOptRuleOperand... rest){
  return new RelOptRuleOperandChildren(RelOptRuleOperandChildPolicy.SOME,ImmutableList.<RelOptRuleOperand>builder().add(first).add(rest).build());
}

Fixed version (ground truth):
/** 
 * Creates a list of child operands that matches child relational expressions in the order they appear.
 * @param first First child operand
 * @param rest  Remaining child operands (may be empty)
 * @return List of child operands that matches child relationalexpressions in the order
 */
public static RelOptRuleOperandChildren some(RelOptRuleOperand first,RelOptRuleOperand... rest){
  return new RelOptRuleOperandChildren(RelOptRuleOperandChildPolicy.SOME,ImmutableList.<RelOptRuleOperand>builder().add(first).add(rest).build());
}
Program: 111813
Project: 111813
Buggy source:
/** 
 * Returns the trait which will be modified as a result of firing this rule, or null if the rule is not a converter rule.
 */
public RelTrait getOutTrait(){
  return null;
}

Fixed version (ground truth):
/** 
 * Returns the trait which will be modified as a result of firing this rule, or null if the rule is not a converter rule.
 * @return Trait which will be modified as a result of firing this rule,or null if the rule is not a converter rule
 */
public RelTrait getOutTrait(){
  return null;
}
Program: 111814
Project: 111814
Buggy source:
/** 
 * Creates an empty list of child operands.
 */
public static RelOptRuleOperandChildren none(){
  return RelOptRuleOperandChildren.LEAF_CHILDREN;
}

Fixed version (ground truth):
/** 
 * Creates an empty list of child operands.
 * @return Empty list of child operands
 */
public static RelOptRuleOperandChildren none(){
  return RelOptRuleOperandChildren.LEAF_CHILDREN;
}
Program: 111815
Project: 111815
Buggy source:
/** 
 * Creates a list of child operands that signifies that the operand matches any number of child relational expressions.
 */
public static RelOptRuleOperandChildren any(){
  return RelOptRuleOperandChildren.ANY_CHILDREN;
}

Fixed version (ground truth):
/** 
 * Creates a list of child operands that signifies that the operand matches any number of child relational expressions.
 * @return List of child operands that signifies that the operand matchesany number of child relational expressions
 */
public static RelOptRuleOperandChildren any(){
  return RelOptRuleOperandChildren.ANY_CHILDREN;
}
Program: 111816
Project: 111816
Buggy source:
/** 
 * Returns the convention of the result of firing this rule, null if not known.
 */
public Convention getOutConvention(){
  return null;
}

Fixed version (ground truth):
/** 
 * Returns the convention of the result of firing this rule, null if not known.
 * @return Convention of the result of firing this rule, null ifnot known
 */
public Convention getOutConvention(){
  return null;
}
Program: 111817
Project: 111817
Buggy source:
/** 
 * Returns whether this rule is equal to another rule. <p>The base implementation checks that the rules have the same class and that the operands are equal; derived classes can override.
 */
protected boolean equals(RelOptRule that){
  return this.description.equals(that.description) && (this.getClass() == that.getClass()) && this.operand.equals(that.operand);
}

Fixed version (ground truth):
/** 
 * Returns whether this rule is equal to another rule. <p>The base implementation checks that the rules have the same class and that the operands are equal; derived classes can override.
 * @param that Another rule
 * @return Whether this rule is equal to another rule
 */
protected boolean equals(RelOptRule that){
  return this.description.equals(that.description) && (this.getClass() == that.getClass()) && this.operand.equals(that.operand);
}
Program: 111818
Project: 111818
Buggy source:
/** 
 * Creates an operand that matches a relational expression with a given list of children. <p>Shorthand for <code>operand(clazz, some(...))</code>. <p>If you wish to match a relational expression that has no children (that is, a leaf node), write <code>operand(clazz, none())</code></p>. <p>If you wish to match a relational expression that has any number of children, write <code>operand(clazz, any())</code></p>.
 * @param clazz Class of relational expression to match (must not be null)
 * @return Operand
 */
public static <R extends RelNode>RelOptRuleOperand operand(Class<R> clazz,RelOptRuleOperand first,RelOptRuleOperand... rest){
  return operand(clazz,some(first,rest));
}

Fixed version (ground truth):
/** 
 * Creates an operand that matches a relational expression with a given list of children. <p>Shorthand for <code>operand(clazz, some(...))</code>. <p>If you wish to match a relational expression that has no children (that is, a leaf node), write <code>operand(clazz, none())</code></p>. <p>If you wish to match a relational expression that has any number of children, write <code>operand(clazz, any())</code></p>.
 * @param clazz Class of relational expression to match (must not be null)
 * @param first First operand
 * @param rest Rest operands
 * @param < R > Class of relational expression to match
 * @return Operand that matches a relational expression with a givenlist of children
 */
public static <R extends RelNode>RelOptRuleOperand operand(Class<R> clazz,RelOptRuleOperand first,RelOptRuleOperand... rest){
  return operand(clazz,some(first,rest));
}
Program: 111819
Project: 111819
Buggy source:
/** 
 * Returns whether this trait subsumes a given trait. <p>Must form a partial order: must be reflective (t subsumes t), anti-symmetric (if t1 subsumes t2 and t1 != t2 then t2 does not subsume t1), and transitive (if t1 subsumes t2 and t2 subsumes t3, then t1 subsumes t3)</p> <p>Many traits cannot be substituted, in which case, this method should return   {@code equals(trait)}.</p>
 */
boolean subsumes(RelTrait trait);

Fixed version (ground truth):
/** 
 * Returns whether this trait subsumes a given trait. <p>Must form a partial order: must be reflective (t subsumes t), anti-symmetric (if t1 subsumes t2 and t1 != t2 then t2 does not subsume t1), and transitive (if t1 subsumes t2 and t2 subsumes t3, then t1 subsumes t3)</p> <p>Many traits cannot be substituted, in which case, this method should return   {@code equals(trait)}.</p>
 * @param trait Given trait
 * @return Whether this trait subsumes a given trait
 */
boolean subsumes(RelTrait trait);
Program: 111820
Project: 111820
Buggy source:
/** 
 * Computes the digest. Does not modify this object.
 */
protected String computeDigest(){
  StringWriter sw=new StringWriter();
  RelWriter pw=new RelWriterImpl(new PrintWriter(sw),SqlExplainLevel.DIGEST_ATTRIBUTES,false){
    protected void explain_(    RelNode rel,    List<Pair<String,Object>> values){
      pw.write(getRelTypeName());
      for (      RelTrait trait : traitSet) {
        pw.write("String_Node_Str");
        pw.write(trait.toString());
      }
      pw.write("String_Node_Str");
      int j=0;
      for (      Pair<String,Object> value : values) {
        if (j++ > 0) {
          pw.write("String_Node_Str");
        }
        pw.write(value.left + "String_Node_Str" + value.right);
      }
      pw.write("String_Node_Str");
    }
  }
;
  explain(pw);
  return sw.toString();
}

Fixed version (ground truth):
/** 
 * Computes the digest. Does not modify this object.
 * @return Digest
 */
protected String computeDigest(){
  StringWriter sw=new StringWriter();
  RelWriter pw=new RelWriterImpl(new PrintWriter(sw),SqlExplainLevel.DIGEST_ATTRIBUTES,false){
    protected void explain_(    RelNode rel,    List<Pair<String,Object>> values){
      pw.write(getRelTypeName());
      for (      RelTrait trait : traitSet) {
        pw.write("String_Node_Str");
        pw.write(trait.toString());
      }
      pw.write("String_Node_Str");
      int j=0;
      for (      Pair<String,Object> value : values) {
        if (j++ > 0) {
          pw.write("String_Node_Str");
        }
        pw.write(value.left + "String_Node_Str" + value.right);
      }
      pw.write("String_Node_Str");
    }
  }
;
  explain(pw);
  return sw.toString();
}
Program: 111821
Project: 111821
Buggy source:
/** 
 * Describes the inputs and attributes of this relational expression. Each node should call   {@code super.explainTerms}, then call the  {@link org.apache.calcite.rel.externalize.RelWriterImpl#input(String,RelNode)}and  {@link org.apache.calcite.rel.externalize.RelWriterImpl#item(String,Object)}methods for each input and attribute.
 * @param pw Plan writer
 */
public RelWriter explainTerms(RelWriter pw){
  return pw;
}

Fixed version (ground truth):
/** 
 * Describes the inputs and attributes of this relational expression. Each node should call   {@code super.explainTerms}, then call the  {@link org.apache.calcite.rel.externalize.RelWriterImpl#input(String,RelNode)}and  {@link org.apache.calcite.rel.externalize.RelWriterImpl#item(String,Object)}methods for each input and attribute.
 * @param pw Plan writer
 * @return Plan writer for fluent-explain pattern
 */
public RelWriter explainTerms(RelWriter pw){
  return pw;
}
Program: 111823
Project: 111823
Buggy source:
protected Object convert(CsvFieldType fieldType,String string){
  if (fieldType == null) {
    return string;
  }
switch (fieldType) {
default :
case STRING:
    return string;
case BOOLEAN:
  if (string.length() == 0) {
    return null;
  }
return Boolean.parseBoolean(string);
case BYTE:
if (string.length() == 0) {
return null;
}
return Byte.parseByte(string);
case SHORT:
if (string.length() == 0) {
return null;
}
return Short.parseShort(string);
case INT:
if (string.length() == 0) {
return null;
}
return Integer.parseInt(string);
case LONG:
if (string.length() == 0) {
return null;
}
return Long.parseLong(string);
case FLOAT:
if (string.length() == 0) {
return null;
}
return Float.parseFloat(string);
case DOUBLE:
if (string.length() == 0) {
return null;
}
return Double.parseDouble(string);
case DATE:
if (string.length() == 0) {
return null;
}
try {
Date date=TIME_FORMAT_DATE.parse(string);
return new java.sql.Date(date.getTime());
}
 catch (ParseException e) {
return null;
}
case TIME:
if (string.length() == 0) {
return null;
}
try {
Date date=TIME_FORMAT_TIME.parse(string);
return new java.sql.Time(date.getTime());
}
 catch (ParseException e) {
return null;
}
case TIMESTAMP:
if (string.length() == 0) {
return null;
}
try {
Date date=TIME_FORMAT_TIMESTAMP.parse(string);
return new java.sql.Timestamp(date.getTime());
}
 catch (ParseException e) {
return null;
}
}
}

Fixed version (ground truth):
protected Object convert(CsvFieldType fieldType,String string){
  if (fieldType == null) {
    return string;
  }
switch (fieldType) {
case BOOLEAN:
    if (string.length() == 0) {
      return null;
    }
  return Boolean.parseBoolean(string);
case BYTE:
if (string.length() == 0) {
  return null;
}
return Byte.parseByte(string);
case SHORT:
if (string.length() == 0) {
return null;
}
return Short.parseShort(string);
case INT:
if (string.length() == 0) {
return null;
}
return Integer.parseInt(string);
case LONG:
if (string.length() == 0) {
return null;
}
return Long.parseLong(string);
case FLOAT:
if (string.length() == 0) {
return null;
}
return Float.parseFloat(string);
case DOUBLE:
if (string.length() == 0) {
return null;
}
return Double.parseDouble(string);
case DATE:
if (string.length() == 0) {
return null;
}
try {
Date date=TIME_FORMAT_DATE.parse(string);
return new java.sql.Date(date.getTime());
}
 catch (ParseException e) {
return null;
}
case TIME:
if (string.length() == 0) {
return null;
}
try {
Date date=TIME_FORMAT_TIME.parse(string);
return new java.sql.Time(date.getTime());
}
 catch (ParseException e) {
return null;
}
case TIMESTAMP:
if (string.length() == 0) {
return null;
}
try {
Date date=TIME_FORMAT_TIMESTAMP.parse(string);
return new java.sql.Timestamp(date.getTime());
}
 catch (ParseException e) {
return null;
}
case STRING:
default :
return string;
}
}
Program: 111824
Project: 111824
Buggy source:
private static void collect(List<String> result,ResultSet resultSet) throws SQLException {
  final StringBuilder buf=new StringBuilder();
  while (resultSet.next()) {
    buf.setLength(0);
    int n=resultSet.getMetaData().getColumnCount();
    String sep="String_Node_Str";
    for (int i=1; i <= n; i++) {
      buf.append(sep).append(resultSet.getMetaData().getColumnLabel(i)).append("String_Node_Str").append(resultSet.getObject(i));
      sep="String_Node_Str";
    }
    result.add(toLinux(buf.toString()));
  }
}

Fixed version (ground truth):
private static void collect(List<String> result,ResultSet resultSet) throws SQLException {
  final StringBuilder buf=new StringBuilder();
  while (resultSet.next()) {
    buf.setLength(0);
    int n=resultSet.getMetaData().getColumnCount();
    String sep="String_Node_Str";
    for (int i=1; i <= n; i++) {
      buf.append(sep).append(resultSet.getMetaData().getColumnLabel(i)).append("String_Node_Str").append(resultSet.getString(i));
      sep="String_Node_Str";
    }
    result.add(toLinux(buf.toString()));
  }
}
Program: 111825
Project: 111825
Buggy source:
public NamedFieldGetter(Class clazz,String... names){
  final List<ColumnMetaData> columns=new ArrayList<ColumnMetaData>();
  for (  String name : names) {
    final int index=fields.size();
    final String fieldName=Util.toCamelCase(name);
    final Field field;
    try {
      field=clazz.getField(fieldName);
    }
 catch (    NoSuchFieldException e) {
      throw new RuntimeException(e);
    }
    columns.add(columnMetaData(name,index,field.getType()));
    fields.add(field);
  }
  structType=ColumnMetaData.struct(columns);
}

Fixed version (ground truth):
public NamedFieldGetter(Class clazz,String... names){
  final List<ColumnMetaData> columns=new ArrayList<ColumnMetaData>();
  init(clazz,names,columns,fields);
  structType=ColumnMetaData.struct(columns);
}
Program: 111826
Project: 111826
Buggy source:
private SubSchemaCache(final OptiqSchema optiqSchema,ImmutableSortedSet<String> names){
  this.names=names;
  this.cache=CacheBuilder.<String,OptiqSchema>newBuilder().build(new CacheLoader<String,OptiqSchema>(){
    @SuppressWarnings("String_Node_Str") @Override public OptiqSchema load(    String schemaName){
      final Schema subSchema=optiqSchema.schema.getSubSchema(schemaName);
      if (subSchema == null) {
        throw new RuntimeException("String_Node_Str" + schemaName + "String_Node_Str");
      }
      return new OptiqSchema(optiqSchema,subSchema,schemaName);
    }
  }
);
}

Fixed version (ground truth):
private SubSchemaCache(final OptiqSchema optiqSchema,ImmutableSortedSet<String> names){
  this.names=names;
  this.cache=CacheBuilder.newBuilder().build(new CacheLoader<String,OptiqSchema>(){
    @SuppressWarnings("String_Node_Str") @Override public OptiqSchema load(    String schemaName){
      final Schema subSchema=optiqSchema.schema.getSubSchema(schemaName);
      if (subSchema == null) {
        throw new RuntimeException("String_Node_Str" + schemaName + "String_Node_Str");
      }
      return new OptiqSchema(optiqSchema,subSchema,schemaName);
    }
  }
);
}
Program: 111827
Project: 111827
Buggy source:
/** 
 * Select distinct on composite key, one column of which is boolean to boot. 
 */
@Test public void testSelectDistinctComposite(){
  OptiqAssert.that().with(OptiqAssert.Config.REGULAR).query("String_Node_Str" + "String_Node_Str").returnsUnordered("String_Node_Str","String_Node_Str","String_Node_Str").planContains("String_Node_Str");
}

Fixed version (ground truth):
/** 
 * Select distinct on composite key, one column of which is boolean to boot. 
 */
@Test public void testSelectDistinctComposite(){
  OptiqAssert.that().with(OptiqAssert.Config.REGULAR).query("String_Node_Str" + "String_Node_Str").returnsUnordered("String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str").planContains("String_Node_Str");
}
Program: 111828
Project: 111828
Buggy source:
static Function1<ResultSet,Void> checkResultUnordered(final String... lines){
  return new Function1<ResultSet,Void>(){
    public Void apply(    ResultSet resultSet){
      try {
        final Collection<String> actualSet=new TreeSet<String>();
        OptiqAssert.toStringList(resultSet,actualSet);
        final TreeSet<String> expectedSet=new TreeSet<String>(Arrays.asList(lines));
        assertEquals(expectedSet,actualSet);
        return null;
      }
 catch (      SQLException e) {
        throw new RuntimeException(e);
      }
    }
  }
;
}

Fixed version (ground truth):
static Function1<ResultSet,Void> checkResultUnordered(final String... lines){
  return new Function1<ResultSet,Void>(){
    public Void apply(    ResultSet resultSet){
      try {
        final List<String> expectedList=new ArrayList<String>();
        Collections.addAll(expectedList,lines);
        Collections.sort(expectedList);
        final List<String> actualList=new ArrayList<String>();
        OptiqAssert.toStringList(resultSet,actualList);
        Collections.sort(actualList);
        assertThat(actualList,equalTo(expectedList));
        return null;
      }
 catch (      SQLException e) {
        throw new RuntimeException(e);
      }
    }
  }
;
}
Program: 111829
Project: 111829
Buggy source:
public PhysType project(final List<Integer> integers,JavaRowFormat format){
  RelDataType projectedRowType=typeFactory.createStructType(new AbstractList<Map.Entry<String,RelDataType>>(){
    public Map.Entry<String,RelDataType> get(    int index){
      return rowType.getFieldList().get(index);
    }
    public int size(){
      return integers.size();
    }
  }
);
  return of(typeFactory,projectedRowType,format.optimize(projectedRowType));
}

Fixed version (ground truth):
public PhysType project(List<Integer> integers,JavaRowFormat format){
  RelDataType projectedRowType=typeFactory.createStructType(Lists.transform(integers,new Function<Integer,RelDataTypeField>(){
    public RelDataTypeField apply(    Integer index){
      return rowType.getFieldList().get(index);
    }
  }
));
  return of(typeFactory,projectedRowType,format.optimize(projectedRowType));
}
Program: 111830
Project: 111830
Buggy source:
public static DataContext createDataContext(Connection schema){
  return new DummyDataContext((OptiqConnection)schema);
}

Fixed version (ground truth):
public static DataContext createDataContext(Connection connection){
  return new DummyDataContext((OptiqConnection)connection);
}
Program: 111831
Project: 111831
Buggy source:
private static OptiqPrepare.Context makeContext(final ConnectionConfig connectionConfig,final JavaTypeFactory typeFactory,final OptiqSchema schema,final List<String> schemaPath){
  return new OptiqPrepare.Context(){
    public JavaTypeFactory getTypeFactory(){
      return typeFactory;
    }
    public OptiqRootSchema getRootSchema(){
      return schema.root();
    }
    public List<String> getDefaultSchemaPath(){
      if (schemaPath == null) {
        return path(schema.schema,null);
      }
      return schemaPath;
    }
    public ConnectionConfig config(){
      return connectionConfig;
    }
    public OptiqPrepare.SparkHandler spark(){
      return OptiqPrepare.Dummy.getSparkHandler();
    }
  }
;
}

Fixed version (ground truth):
private static OptiqPrepare.Context makeContext(final ConnectionConfig connectionConfig,final JavaTypeFactory typeFactory,final DataContext dataContext,final OptiqSchema schema,final List<String> schemaPath){
  return new OptiqPrepare.Context(){
    public JavaTypeFactory getTypeFactory(){
      return typeFactory;
    }
    public OptiqRootSchema getRootSchema(){
      return schema.root();
    }
    public List<String> getDefaultSchemaPath(){
      if (schemaPath == null) {
        return path(schema.schema,null);
      }
      return schemaPath;
    }
    public ConnectionConfig config(){
      return connectionConfig;
    }
    public DataContext getDataContext(){
      return dataContext;
    }
    public OptiqPrepare.SparkHandler spark(){
      return OptiqPrepare.Dummy.getSparkHandler();
    }
  }
;
}
Program: 111833
Project: 111833
Buggy source:
public OptiqPreparingStmt(Context context,CatalogReader catalogReader,RelDataTypeFactory typeFactory,OptiqSchema schema,EnumerableRel.Prefer prefer,RelOptPlanner planner,Convention resultConvention){
}

Fixed version (ground truth):
public OptiqPreparingStmt(Context context,CatalogReader catalogReader,RelDataTypeFactory typeFactory,OptiqSchema schema,EnumerableRel.Prefer prefer,RelOptPlanner planner,Convention resultConvention){
  super(context,catalogReader,resultConvention);
  this.schema=schema;
  this.prefer=prefer;
  this.planner=planner;
  this.typeFactory=typeFactory;
  this.rexBuilder=new RexBuilder(typeFactory);
}
Program: 111834
Project: 111834
Buggy source:
public Prepare(CatalogReader catalogReader,Convention resultConvention){
  this.catalogReader=catalogReader;
  this.resultConvention=resultConvention;
}

Fixed version (ground truth):
public Prepare(OptiqPrepare.Context context,CatalogReader catalogReader,Convention resultConvention){
}
Program: 111836
Project: 111836
Buggy source:
@Override public Expression visit(BinaryExpression binaryExpression,Expression expression0,Expression expression1){
  final BinaryExpression binary=(BinaryExpression)super.visit(binaryExpression,expression0,expression1);
  Boolean always;
switch (binary.getNodeType()) {
case AndAlso:
    always=always(binary.expression0);
  if (always != null) {
    return always ? binary.expression1 : FALSE_EXPR;
  }
always=always(binary.expression1);
if (always != null) {
return always ? binary.expression0 : FALSE_EXPR;
}
break;
case OrElse:
always=always(binary.expression0);
if (always != null) {
return !always ? binary.expression1 : TRUE_EXPR;
}
always=always(binary.expression1);
if (always != null) {
return !always ? binary.expression0 : TRUE_EXPR;
}
break;
case Equal:
if (binary.expression0 instanceof ConstantExpression && binary.expression1 instanceof ConstantExpression) {
return binary.expression0.equals(binary.expression1) ? TRUE_EXPR : FALSE_EXPR;
}
break;
case NotEqual:
if (binary.expression0 instanceof ConstantExpression && binary.expression1 instanceof ConstantExpression) {
return !binary.expression0.equals(binary.expression1) ? TRUE_EXPR : FALSE_EXPR;
}
break;
}
return binary;
}

Fixed version (ground truth):
@Override public Expression visit(BinaryExpression binaryExpression,Expression expression0,Expression expression1){
  final BinaryExpression binary=(BinaryExpression)super.visit(binaryExpression,expression0,expression1);
  Boolean always;
switch (binary.getNodeType()) {
case AndAlso:
    always=always(binary.expression0);
  if (always != null) {
    return always ? binary.expression1 : FALSE_EXPR;
  }
always=always(binary.expression1);
if (always != null) {
return always ? binary.expression0 : FALSE_EXPR;
}
break;
case OrElse:
always=always(binary.expression0);
if (always != null) {
return !always ? binary.expression1 : TRUE_EXPR;
}
always=always(binary.expression1);
if (always != null) {
return !always ? binary.expression0 : TRUE_EXPR;
}
break;
case Equal:
if (binary.expression0 instanceof ConstantExpression && binary.expression1 instanceof ConstantExpression) {
return binary.expression0.equals(binary.expression1) ? TRUE_EXPR : FALSE_EXPR;
}
if (isConstantNull(binary.expression1) && Primitive.is(binary.expression0.getType())) {
return FALSE_EXPR;
}
if (isConstantNull(binary.expression0) && Primitive.is(binary.expression1.getType())) {
return FALSE_EXPR;
}
break;
case NotEqual:
if (binary.expression0 instanceof ConstantExpression && binary.expression1 instanceof ConstantExpression) {
return !binary.expression0.equals(binary.expression1) ? TRUE_EXPR : FALSE_EXPR;
}
if (isConstantNull(binary.expression1) && Primitive.is(binary.expression0.getType())) {
return TRUE_EXPR;
}
if (isConstantNull(binary.expression0) && Primitive.is(binary.expression1.getType())) {
return TRUE_EXPR;
}
break;
}
return binary;
}
Program: 111837
Project: 111837
Buggy source:
/** 
 * Translates an expression that is not in the cache.
 * @param expr Expression
 * @param nullAs If false, if expression is definitely not null atruntime. Therefore we can optimize. For example, we can cast to int using x.intValue().
 * @return Translated expression
 */
private Expression translate0(RexNode expr,RexImpTable.NullAs nullAs){
  if (nullAs == RexImpTable.NullAs.NULL && !expr.getType().isNullable()) {
    nullAs=RexImpTable.NullAs.NOT_POSSIBLE;
  }
switch (expr.getKind()) {
case INPUT_REF:
    final int index=((RexInputRef)expr).getIndex();
  Expression x=inputGetter.field(list,index);
return list.append("String_Node_Str",nullAs.handle(list.append("String_Node_Str",x)));
case LOCAL_REF:
return translate(program.getExprList().get(((RexLocalRef)expr).getIndex()),nullAs);
case LITERAL:
return translateLiteral(expr,nullifyType(expr.getType(),isNullable(expr) && nullAs != RexImpTable.NullAs.NOT_POSSIBLE),typeFactory,nullAs);
case DYNAMIC_PARAM:
return translateParameter((RexDynamicParam)expr,nullAs);
default :
if (expr instanceof RexCall) {
final RexCall call=(RexCall)expr;
final SqlOperator operator=call.getOperator();
RexImpTable.CallImplementor implementor=RexImpTable.INSTANCE.get(operator);
if (implementor != null) {
return implementor.implement(this,call,nullAs);
}
}
throw new RuntimeException("String_Node_Str" + expr);
}
}

Fixed version (ground truth):
/** 
 * Translates an expression that is not in the cache.
 * @param expr Expression
 * @param nullAs If false, if expression is definitely not null atruntime. Therefore we can optimize. For example, we can cast to int using x.intValue().
 * @return Translated expression
 */
private Expression translate0(RexNode expr,RexImpTable.NullAs nullAs){
  if (nullAs == RexImpTable.NullAs.NULL && !expr.getType().isNullable()) {
    nullAs=RexImpTable.NullAs.NOT_POSSIBLE;
  }
switch (expr.getKind()) {
case INPUT_REF:
    final int index=((RexInputRef)expr).getIndex();
  Expression x=inputGetter.field(list,index);
return list.append("String_Node_Str",nullAs.handle(list.append("String_Node_Str",x)));
case LOCAL_REF:
return translate(program.getExprList().get(((RexLocalRef)expr).getIndex()),nullAs);
case LITERAL:
return translateLiteral(expr,nullifyType(expr.getType(),isNullable(expr) && nullAs != RexImpTable.NullAs.NOT_POSSIBLE),typeFactory,nullAs);
case DYNAMIC_PARAM:
return translateParameter((RexDynamicParam)expr,nullAs);
default :
if (expr instanceof RexCall) {
return translateCall((RexCall)expr,nullAs);
}
throw new RuntimeException("String_Node_Str" + expr);
}
}
Program: 111838
Project: 111838
Buggy source:
public Expression generateAccessor(List<Integer> fields){
  ParameterExpression v1=Expressions.parameter(javaRowClass,"String_Node_Str");
switch (fields.size()) {
case 0:
    return Expressions.lambda(Function1.class,Expressions.field(null,Collections.class,"String_Node_Str"),v1);
case 1:
  int field0=fields.get(0);
Class returnType=fieldClasses.get(field0);
Expression fieldReference=Types.castIfNecessary(returnType,fieldReference(v1,field0));
return Expressions.lambda(Function1.class,fieldReference,v1);
default :
Expressions.FluentList<Expression> list=Expressions.list();
for (int field : fields) {
list.add(fieldReference(v1,field));
}
switch (list.size()) {
case 2:
return Expressions.lambda(Function1.class,Expressions.call(List.class,null,BuiltinMethod.LIST2.method,list),v1);
case 3:
return Expressions.lambda(Function1.class,Expressions.call(List.class,null,BuiltinMethod.LIST3.method,list),v1);
default :
return Expressions.lambda(Function1.class,Expressions.call(BuiltinMethod.ARRAYS_AS_LIST.method,Expressions.newArrayInit(Object.class,list)),v1);
}
}
}

Fixed version (ground truth):
public Expression generateAccessor(List<Integer> fields){
  ParameterExpression v1=Expressions.parameter(javaRowClass,"String_Node_Str");
switch (fields.size()) {
case 0:
    return Expressions.lambda(Function1.class,Expressions.field(null,Collections.class,"String_Node_Str"),v1);
case 1:
  int field0=fields.get(0);
Class returnType=fieldClasses.get(field0);
Expression fieldReference=Types.castIfNecessary(returnType,fieldReference(v1,field0));
return Expressions.lambda(Function1.class,fieldReference,v1);
default :
Expressions.FluentList<Expression> list=Expressions.list();
for (int field : fields) {
list.add(fieldReference(v1,field));
}
switch (list.size()) {
case 2:
return Expressions.lambda(Function1.class,Expressions.call(List.class,null,BuiltinMethod.LIST2.method,list),v1);
case 3:
return Expressions.lambda(Function1.class,Expressions.call(List.class,null,BuiltinMethod.LIST3.method,list),v1);
default :
return Expressions.lambda(Function1.class,Expressions.call(List.class,null,BuiltinMethod.ARRAYS_AS_LIST.method,Expressions.newArrayInit(Object.class,list)),v1);
}
}
}
Program: 111839
Project: 111839
Buggy source:
/** 
 * A selection of queries generated by Mondrian. 
 */
@Ignore @Test public void testCloneQueries(){
  OptiqAssert.AssertThat with=OptiqAssert.assertThat().with(OptiqAssert.Config.FOODMART_CLONE);
  for (  Ord<Pair<String,String>> query : Ord.zip(FOODMART_QUERIES)) {
    try {
      final String sql=query.e.left;
      final String expected=query.e.right;
      final OptiqAssert.AssertQuery query1=with.query(sql);
      if (expected != null) {
        if (sql.contains("String_Node_Str")) {
          query1.returns(expected);
        }
 else {
          query1.returnsUnordered(expected.split("String_Node_Str"));
        }
      }
 else {
        query1.runs();
      }
    }
 catch (    Throwable e) {
      throw new RuntimeException("String_Node_Str" + query.i,e);
    }
  }
}

Fixed version (ground truth):
/** 
 * A selection of queries generated by Mondrian. 
 */
@Test public void testCloneQueries(){
  OptiqAssert.AssertThat with=OptiqAssert.assertThat().with(OptiqAssert.Config.FOODMART_CLONE);
  for (  Ord<Pair<String,String>> query : Ord.zip(FOODMART_QUERIES)) {
    try {
      final String sql=query.e.left;
      if (sql.startsWith("String_Node_Str")) {
        continue;
      }
      final String expected=query.e.right;
      final OptiqAssert.AssertQuery query1=with.query(sql);
      if (expected != null) {
        if (sql.contains("String_Node_Str")) {
          query1.returns(expected);
        }
 else {
          query1.returnsUnordered(expected.split("String_Node_Str"));
        }
      }
 else {
        query1.runs();
      }
    }
 catch (    Throwable e) {
      throw new RuntimeException("String_Node_Str" + query.i,e);
    }
  }
}
Program: 111840
Project: 111840
Buggy source:
/** 
 * Returns the child of a project if the project is trivial, otherwise the project itself. 
 */
public static RelNode strip(ProjectRel project){
  return isTrivial(project) ? project : project.getChild();
}

Fixed version (ground truth):
/** 
 * Returns the child of a project if the project is trivial, otherwise the project itself. 
 */
public static RelNode strip(ProjectRel project){
  return isTrivial(project) ? project.getChild() : project;
}
Program: 111841
Project: 111841
Buggy source:
public AssertQuery query(String sql){
  System.out.println(sql);
  return new AssertQuery(connectionFactory,sql);
}

Fixed version (ground truth):
public AssertQuery query(String sql){
  return new AssertQuery(connectionFactory,sql);
}
Program: 111842
Project: 111842
Buggy source:
/** 
 * Adapt for some types that we represent differently internally than their JDBC types.   {@link java.sql.Timestamp} values that are not null areconverted to  {@code long}, but nullable timestamps are acquired using  {@link java.sql.ResultSet#getObject(int)} and therefore the Timestampvalue needs to be converted to a  {@link Long}. Similarly  {@link java.sql.Date} and {@link java.sql.Time} values to{@link Integer}. 
 */
private static List wrap(List list,RelDataType type){
switch (type.getSqlTypeName()) {
case TIMESTAMP:
    return Functions.adapt(list,TIMESTAMP_TO_LONG);
case TIME:
  return Functions.adapt(list,TIME_TO_INT);
case DATE:
return Functions.adapt(list,DATE_TO_INT);
}
return list;
}

Fixed version (ground truth):
/** 
 * Adapt for some types that we represent differently internally than their JDBC types.   {@link java.sql.Timestamp} values that are not null areconverted to  {@code long}, but nullable timestamps are acquired using  {@link java.sql.ResultSet#getObject(int)} and therefore the Timestampvalue needs to be converted to a  {@link Long}. Similarly  {@link java.sql.Date} and {@link java.sql.Time} values to{@link Integer}. 
 */
private static List wrap(List list,RelDataType type){
  if (type.isNullable()) {
switch (type.getSqlTypeName()) {
case TIMESTAMP:
      return Functions.adapt(list,TIMESTAMP_TO_LONG);
case TIME:
    return Functions.adapt(list,TIME_TO_INT);
case DATE:
  return Functions.adapt(list,DATE_TO_INT);
}
}
return list;
}
Program: 111843
Project: 111843
Buggy source:
/** 
 * Returns a list of relational expressions one of whose children is this subset. The elements of the list are distinct. 
 */
public List<RelNode> getParentRels(){
}

Fixed version (ground truth):
/** 
 * Returns a list of relational expressions one of whose children is this subset. The elements of the list are distinct. 
 */
public Collection<RelNode> getParentRels(){
  final Set<RelNode> list=new LinkedHashSet<RelNode>();
  parentLoop:   for (  RelNode parent : set.getParentRels()) {
    for (    RelSubset rel : inputSubsets(parent)) {
      if (rel.set == set && rel.getTraitSet().equals(traitSet)) {
        list.add(parent);
        continue parentLoop;
      }
    }
  }
  return list;
}
Program: 111845
Project: 111845
Buggy source:
@Override protected Collection<TableInSchema> initialTables(){
  final List<TableInSchema> list=new ArrayList<TableInSchema>();
  File[] files=directoryFile.listFiles(new FilenameFilter(){
    public boolean accept(    File dir,    String name){
      return name.endsWith("String_Node_Str");
    }
  }
);
  for (  File file : files) {
    String tableName=file.getName();
    if (tableName.endsWith("String_Node_Str")) {
      tableName=tableName.substring(0,tableName.length() - "String_Node_Str".length());
    }
    final List<CsvFieldType> fieldTypes=new ArrayList<CsvFieldType>();
    final RelDataType rowType=CsvTable.deduceRowType(typeFactory,file,fieldTypes);
    final CsvTable table;
    if (smart) {
      table=new CsvSmartTable(this,tableName,file,rowType,fieldTypes);
    }
 else {
      table=new CsvTable(this,tableName,file,rowType,fieldTypes);
    }
    list.add(new TableInSchemaImpl(this,tableName,TableType.TABLE,table));
  }
  return list;
}

Fixed version (ground truth):
@Override protected Collection<TableInSchema> initialTables(){
  final List<TableInSchema> list=new ArrayList<TableInSchema>();
  File[] files=directoryFile.listFiles(new FilenameFilter(){
    public boolean accept(    File dir,    String name){
      return name.endsWith("String_Node_Str");
    }
  }
);
  if (files == null) {
    System.out.println("String_Node_Str" + directoryFile + "String_Node_Str");
    files=new File[0];
  }
  for (  File file : files) {
    String tableName=file.getName();
    if (tableName.endsWith("String_Node_Str")) {
      tableName=tableName.substring(0,tableName.length() - "String_Node_Str".length());
    }
    final List<CsvFieldType> fieldTypes=new ArrayList<CsvFieldType>();
    final RelDataType rowType=CsvTable.deduceRowType(typeFactory,file,fieldTypes);
    final CsvTable table;
    if (smart) {
      table=new CsvSmartTable(this,tableName,file,rowType,fieldTypes);
    }
 else {
      table=new CsvTable(this,tableName,file,rowType,fieldTypes);
    }
    list.add(new TableInSchemaImpl(this,tableName,TableType.TABLE,table));
  }
  return list;
}
Program: 111846
Project: 111846
Buggy source:
public Integer apply(Date a0){
  return a0 == null ? null : (int)(a0.getTime() / 86400000);
}

Fixed version (ground truth):
public Integer apply(Date a0){
  return a0 == null ? null : (int)(a0.getTime() / DateTimeUtil.MILLIS_PER_DAY);
}
Program: 111847
Project: 111847
Buggy source:
/** 
 * Adapt for some types that we represent differently internally than their JDBC types.   {@link java.sql.Timestamp} values that are not null areconverted to  {@code long}, but nullable timestamps are acquired using  {@link java.sql.ResultSet#getObject(int)} and therefore the Timestampvalue needs to be converted to a  {@link Long}. Similarly  {@link java.sql.Date} and {@link java.sql.Time} values to{@link Integer}. 
 */
private static List wrap(List list,RelDataType type){
  if (type.isNullable()) {
switch (type.getSqlTypeName()) {
case TIMESTAMP:
      return Functions.adapt(list,TIMESTAMP_TO_LONG);
case TIME:
    return Functions.adapt(list,TIME_TO_INT);
case DATE:
  return Functions.adapt(list,DATE_TO_INT);
}
}
return list;
}

Fixed version (ground truth):
/** 
 * Adapt for some types that we represent differently internally than their JDBC types.   {@link java.sql.Timestamp} values that are not null areconverted to  {@code long}, but nullable timestamps are acquired using  {@link java.sql.ResultSet#getObject(int)} and therefore the Timestampvalue needs to be converted to a  {@link Long}. Similarly  {@link java.sql.Date} and {@link java.sql.Time} values to{@link Integer}. 
 */
private static List wrap(List list,RelDataType type){
switch (type.getSqlTypeName()) {
case TIMESTAMP:
    return Functions.adapt(list,TIMESTAMP_TO_LONG);
case TIME:
  return Functions.adapt(list,TIME_TO_INT);
case DATE:
return Functions.adapt(list,DATE_TO_INT);
}
return list;
}
Program: 111848
Project: 111848
Buggy source:
public Enumerator<Object[]> enumerator(){
  final SqlString sql=generateSql();
  Function1<ResultSet,Function0<Object[]>> rowBuilderFactory=JdbcUtils.ObjectArrayRowBuilder.factory(JdbcUtils.getPrimitives(schema.typeFactory,rowType));
  return ResultSetEnumerable.of(schema.getDataSource(),sql.getSql(),rowBuilderFactory).enumerator();
}

Fixed version (ground truth):
public Enumerator<Object[]> enumerator(){
  final SqlString sql=generateSql();
  return ResultSetEnumerable.of(schema.getDataSource(),sql.getSql(),JdbcUtils.ObjectArrayRowBuilder.factory(fieldClasses())).enumerator();
}
Program: 111849
Project: 111849
Buggy source:
public static Function1<ResultSet,Function0<Object[]>> factory(List<Primitive> primitiveList){
  final Primitive[] primitives=primitiveList.toArray(new Primitive[primitiveList.size()]);
  return new Function1<ResultSet,Function0<Object[]>>(){
    public Function0<Object[]> apply(    ResultSet resultSet){
      try {
        return new ObjectArrayRowBuilder(resultSet,primitives);
      }
 catch (      SQLException e) {
        throw new RuntimeException(e);
      }
    }
  }
;
}

Fixed version (ground truth):
public static Function1<ResultSet,Function0<Object[]>> factory(final List<Pair<Primitive,Integer>> list){
  return new Function1<ResultSet,Function0<Object[]>>(){
    public Function0<Object[]> apply(    ResultSet resultSet){
      try {
        return new ObjectArrayRowBuilder(resultSet,Pair.left(list).toArray(new Primitive[list.size()]),IntList.toArray(Pair.right(list)));
      }
 catch (      SQLException e) {
        throw new RuntimeException(e);
      }
    }
  }
;
}
Program: 111850
Project: 111850
Buggy source:
public ObjectArrayRowBuilder(ResultSet resultSet,Primitive[] primitives) throws SQLException {
  this.resultSet=resultSet;
  this.primitives=primitives;
  this.columnCount=resultSet.getMetaData().getColumnCount();
}

Fixed version (ground truth):
public ObjectArrayRowBuilder(ResultSet resultSet,Primitive[] primitives,int[] types) throws SQLException {
  this.resultSet=resultSet;
  this.primitives=primitives;
  this.types=types;
  this.columnCount=resultSet.getMetaData().getColumnCount();
}
Program: 111851
Project: 111851
Buggy source:
private Object value(int i) throws SQLException {
  return primitives[i].jdbcGet(resultSet,i + 1);
}

Fixed version (ground truth):
/** 
 * Gets a value from a given column in a JDBC result set.
 * @param i Ordinal of column (1-based, per JDBC)
 */
private Object value(int i) throws SQLException {
switch (types[i]) {
case Types.TIMESTAMP:
    return shift(resultSet.getTimestamp(i + 1));
case Types.TIME:
  return shift(resultSet.getTime(i + 1));
case Types.DATE:
return shift(resultSet.getDate(i + 1));
}
return primitives[i].jdbcGet(resultSet,i + 1);
}
Program: 111852
Project: 111852
Buggy source:
public NamedFieldGetter(Class clazz,String... names){
  for (  String name : names) {
    final int index=fields.size();
    final String fieldName=uncamel(name);
    final Field field;
    try {
      field=clazz.getField(fieldName);
    }
 catch (    NoSuchFieldException e) {
      throw new RuntimeException(e);
    }
    Pair<Integer,String> pair=lookupType(field.getType());
    columnNames.add(new ColumnMetaData(index,false,true,false,false,Primitive.is(field.getType()) ? DatabaseMetaData.columnNullable : DatabaseMetaData.columnNoNulls,true,-1,name,name,null,0,0,null,null,pair.left,pair.right,true,false,false,null,field.getType()));
    fields.add(field);
  }
}

Fixed version (ground truth):
public NamedFieldGetter(Class clazz,String... names){
  for (  String name : names) {
    final int index=fields.size();
    final String fieldName=uncamel(name);
    final Field field;
    try {
      field=clazz.getField(fieldName);
    }
 catch (    NoSuchFieldException e) {
      throw new RuntimeException(e);
    }
    Pair<Integer,String> pair=lookupType(field.getType());
    ColumnMetaData.Rep rep=ColumnMetaData.Rep.VALUE_MAP.get(field.getType());
    columnNames.add(new ColumnMetaData(index,false,true,false,false,Primitive.is(field.getType()) ? DatabaseMetaData.columnNullable : DatabaseMetaData.columnNoNulls,true,-1,name,name,null,0,0,null,null,pair.left,pair.right,true,false,false,null,rep));
    fields.add(field);
  }
}
Program: 111853
Project: 111853
Buggy source:
public boolean wasNull() throws SQLException {
  return wasNull[0];
}

Fixed version (ground truth):
public boolean wasNull() throws SQLException {
  return cursor.wasNull();
}
Program: 111854
Project: 111854
Buggy source:
private List<ColumnMetaData> getColumnMetaDataList(JavaTypeFactory typeFactory,RelDataType x,RelDataType jdbcType,List<List<String>> originList){
  final List<ColumnMetaData> columns=new ArrayList<ColumnMetaData>();
  for (  Ord<RelDataTypeField> pair : Ord.zip(jdbcType.getFieldList())) {
    final RelDataTypeField field=pair.e;
    RelDataType type=field.getType();
    List<String> origins=originList.get(pair.i);
    SqlTypeName sqlTypeName=type.getSqlTypeName();
    final String typeName;
switch (sqlTypeName) {
case INTERVAL_YEAR_MONTH:
case INTERVAL_DAY_TIME:
      typeName="String_Node_Str" + type.getIntervalQualifier().toString().replace(' ','_');
    break;
default :
  typeName=sqlTypeName.getName();
}
columns.add(new ColumnMetaData(columns.size(),false,true,false,false,type.isNullable() ? 1 : 0,true,type.getPrecision(),field.getName(),origins == null ? null : origins.get(2),origins == null ? null : origins.get(0),type.getPrecision() == RelDataType.PRECISION_NOT_SPECIFIED ? 0 : type.getPrecision(),type.getScale() == RelDataType.SCALE_NOT_SPECIFIED ? 0 : type.getScale(),origins == null ? null : origins.get(1),null,sqlTypeName.getJdbcOrdinal(),typeName,true,false,false,null,(Class)typeFactory.getJavaClass(x.isStruct() ? x.getFieldList().get(pair.i).getType() : type)));
}
return columns;
}

Fixed version (ground truth):
private List<ColumnMetaData> getColumnMetaDataList(JavaTypeFactory typeFactory,RelDataType x,RelDataType jdbcType,List<List<String>> originList){
}