Skip to content

Instantly share code, notes, and snippets.

@masayuki038
Created November 9, 2019 07:11
Show Gist options
  • Save masayuki038/cd53ed5f066e32cf36403670c093f0db to your computer and use it in GitHub Desktop.
Save masayuki038/cd53ed5f066e32cf36403670c093f0db to your computer and use it in GitHub Desktop.
package net.wrap_trap.calcite_avro_sample;
import org.apache.calcite.model.ModelHandler;
import org.apache.calcite.schema.Schema;
import org.apache.calcite.schema.SchemaFactory;
import org.apache.calcite.schema.SchemaPlus;
import java.io.File;
import java.util.Map;
public class AvroSchemaFactory implements SchemaFactory {
public Schema create(SchemaPlus parentSchema, String name, Map<String, Object> operand) {
String directory = (String) operand.get("directory");
File base = (File) operand.get(ModelHandler.ExtraOperand.BASE_DIRECTORY.camelName);
File directoryFile = new File(directory);
if (base != null && !directoryFile.isAbsolute()) {
directoryFile = new File(base, directory);
}
return new AvroSchema(directoryFile);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment