public void createDatabase(@Nullable QueryContext queryContext, String databaseName, @Nullable String tablespace, boolean ifNotExists) throws IOException, DuplicateDatabaseException { String tablespaceName; if (tablespace == null) { tablespaceName = DEFAULT_TABLESPACE_NAME; } else { tablespaceName = tablespace; } // CREATE DATABASE IF NOT EXISTS boolean exists = catalog.existDatabase(databaseName); if (exists) { if (ifNotExists) { LOG.info("database \"" + databaseName + "\" is already exists."); return; } else { throw new DuplicateDatabaseException(databaseName); } } String normalized = databaseName; Path databaseDir = StorageUtil.concatPath(context.getConf().getVar(TajoConf.ConfVars.WAREHOUSE_DIR), normalized); FileSystem fs = databaseDir.getFileSystem(context.getConf()); fs.mkdirs(databaseDir); catalog.createDatabase(databaseName, tablespaceName); LOG.info("database \"" + databaseName + "\" created."); }
public void createDatabase(@Nullable QueryContext queryContext, String databaseName, @Nullable String tablespace, boolean ifNotExists) throws IOException, DuplicateDatabaseException { String tablespaceName; if (tablespace == null) { tablespaceName = DEFAULT_TABLESPACE_NAME; } else { tablespaceName = tablespace; } // CREATE DATABASE IF NOT EXISTS boolean exists = catalog.existDatabase(databaseName); if (exists) { if (ifNotExists) { LOG.info("database \"" + databaseName + "\" is already exists."); return; } else { throw new DuplicateDatabaseException(databaseName); } } String normalized = databaseName; Path databaseDir = StorageUtil.concatPath(context.getConf().getVar(TajoConf.ConfVars.WAREHOUSE_DIR), normalized); FileSystem fs = databaseDir.getFileSystem(context.getConf()); fs.mkdirs(databaseDir); catalog.createDatabase(databaseName, tablespaceName); LOG.info("database \"" + databaseName + "\" created."); }
@Override public Response run(JerseyResourceDelegateContext context) { JerseyResourceDelegateContextKey<NewDatabaseRequest> newDatabaseRequestKey = JerseyResourceDelegateContextKey.valueOf(newDatabaseRequestKeyName, NewDatabaseRequest.class); NewDatabaseRequest request = context.get(newDatabaseRequestKey); JerseyResourceDelegateContextKey<MasterContext> masterContextKey = JerseyResourceDelegateContextKey.valueOf(JerseyResourceDelegateUtil.MasterContextKey, MasterContext.class); MasterContext masterContext = context.get(masterContextKey); JerseyResourceDelegateContextKey<UriInfo> uriInfoKey = JerseyResourceDelegateContextKey.valueOf(JerseyResourceDelegateUtil.UriInfoKey, UriInfo.class); UriInfo uriInfo = context.get(uriInfoKey); if (request.getDatabaseName() == null || request.getDatabaseName().isEmpty()) { return ResourcesUtil.createBadRequestResponse(LOG, "databaseName is null or empty."); } try { masterContext.getCatalog().createDatabase(request.getDatabaseName(), TajoConstants.DEFAULT_TABLESPACE_NAME); URI newDatabaseURI = uriInfo.getBaseUriBuilder() .path(DatabasesResource.class) .path(DatabasesResource.class, "getDatabase") .build(request.getDatabaseName()); return Response.created(newDatabaseURI).build(); } catch (TajoException e) { return ResourcesUtil.createExceptionResponse(LOG, e.getMessage()); } } }
@Override public Response run(JerseyResourceDelegateContext context) { JerseyResourceDelegateContextKey<NewDatabaseRequest> newDatabaseRequestKey = JerseyResourceDelegateContextKey.valueOf(newDatabaseRequestKeyName, NewDatabaseRequest.class); NewDatabaseRequest request = context.get(newDatabaseRequestKey); JerseyResourceDelegateContextKey<MasterContext> masterContextKey = JerseyResourceDelegateContextKey.valueOf(JerseyResourceDelegateUtil.MasterContextKey, MasterContext.class); MasterContext masterContext = context.get(masterContextKey); JerseyResourceDelegateContextKey<UriInfo> uriInfoKey = JerseyResourceDelegateContextKey.valueOf(JerseyResourceDelegateUtil.UriInfoKey, UriInfo.class); UriInfo uriInfo = context.get(uriInfoKey); if (request.getDatabaseName() == null || request.getDatabaseName().isEmpty()) { return ResourcesUtil.createBadRequestResponse(LOG, "databaseName is null or empty."); } try { masterContext.getCatalog().createDatabase(request.getDatabaseName(), TajoConstants.DEFAULT_TABLESPACE_NAME); URI newDatabaseURI = uriInfo.getBaseUriBuilder() .path(DatabasesResource.class) .path(DatabasesResource.class, "getDatabase") .build(request.getDatabaseName()); return Response.created(newDatabaseURI).build(); } catch (TajoException e) { return ResourcesUtil.createExceptionResponse(LOG, e.getMessage()); } } }
@BeforeClass public static void setUp() throws Exception { cluster = new TajoTestingCluster(); conf = cluster.getConfiguration(); cluster.startCatalogCluster(); cat = cluster.getCatalogService(); cat.createTablespace(DEFAULT_TABLESPACE_NAME, "hdfs://localhost:1234/warehouse"); cat.createDatabase(DEFAULT_DATABASE_NAME, DEFAULT_TABLESPACE_NAME); Map<FunctionSignature, FunctionDesc> map = FunctionLoader.loadBuiltinFunctions(); List<FunctionDesc> list = new ArrayList<>(map.values()); list.addAll(FunctionLoader.loadUserDefinedFunctions(conf).orElse(new ArrayList<>())); // load Hive UDFs URL hiveUDFURL = ClassLoader.getSystemResource("hiveudf"); Preconditions.checkNotNull(hiveUDFURL, "hive udf directory is absent."); conf.set(TajoConf.ConfVars.HIVE_UDF_JAR_DIR.varname, hiveUDFURL.toString().substring("file:".length())); list.addAll(HiveFunctionLoader.loadHiveUDFs(conf).orElse(new ArrayList<>())); for (FunctionDesc funcDesc : list) { cat.createFunction(funcDesc); } analyzer = new SQLAnalyzer(); preLogicalPlanVerifier = new PreLogicalPlanVerifier(cat); planner = new LogicalPlanner(cat, TablespaceManager.getInstance()); optimizer = new LogicalOptimizer(cluster.getConfiguration(), cat, TablespaceManager.getInstance()); annotatedPlanVerifier = new LogicalPlanVerifier(); }
testDir = CommonTestingUtil.getTestDir(TEST_PATH); catalog.createTablespace(DEFAULT_TABLESPACE_NAME, testDir.toUri().toString()); catalog.createDatabase(TajoConstants.DEFAULT_DATABASE_NAME, DEFAULT_TABLESPACE_NAME); conf.setVar(TajoConf.ConfVars.WORKER_TEMPORAL_DIR, testDir.toString());
testDir = CommonTestingUtil.getTestDir(TEST_PATH); catalog.createTablespace(DEFAULT_TABLESPACE_NAME, testDir.toUri().toString()); catalog.createDatabase(DEFAULT_DATABASE_NAME, DEFAULT_TABLESPACE_NAME); conf.setVar(TajoConf.ConfVars.WORKER_TEMPORAL_DIR, testDir.toString());
catalog = util.getCatalogService(); catalog.createTablespace(DEFAULT_TABLESPACE_NAME, "hdfs://localhost:1234/warehouse"); catalog.createDatabase(DEFAULT_DATABASE_NAME, DEFAULT_TABLESPACE_NAME); for (FunctionDesc funcDesc : FunctionLoader.findLegacyFunctions()) { catalog.createFunction(funcDesc);
@BeforeClass public static void setUp() throws Exception { util = new TajoTestingCluster(); util.startCatalogCluster(); conf = util.getConfiguration(); conf.set(TajoConf.ConfVars.$TEST_BROADCAST_JOIN_ENABLED.varname, "false"); catalog = util.getCatalogService(); catalog.createTablespace(DEFAULT_TABLESPACE_NAME, "hdfs://localhost:!234/warehouse"); catalog.createDatabase(DEFAULT_DATABASE_NAME, DEFAULT_TABLESPACE_NAME); TPCH tpch = new TPCH(); tpch.loadSchemas(); tpch.loadOutSchema(); for (String table : tpch.getTableNames()) { TableMeta m = CatalogUtil.newTableMeta(BuiltinStorages.TEXT, util.getConfiguration()); TableDesc d = CatalogUtil.newTableDesc( IdentifierUtil.buildFQName(DEFAULT_DATABASE_NAME, table), tpch.getSchema(table), m, CommonTestingUtil.getTestDir()); TableStats stats = new TableStats(); stats.setNumBytes(TPCH.tableVolumes.get(table)); d.setStats(stats); catalog.createTable(d); } analyzer = new SQLAnalyzer(); logicalPlanner = new LogicalPlanner(catalog, TablespaceManager.getInstance()); optimizer = new LogicalOptimizer(conf, catalog, TablespaceManager.getInstance()); dispatcher = new AsyncDispatcher(); dispatcher.init(conf); dispatcher.start(); planner = new GlobalPlanner(conf, catalog); }
@BeforeClass public static void setUp() throws Exception { util = new TajoTestingCluster(); util.startCatalogCluster(); catalog = util.getCatalogService(); catalog.createTablespace(DEFAULT_TABLESPACE_NAME, "hdfs://localhost:1234"); catalog.createDatabase(DEFAULT_DATABASE_NAME, DEFAULT_TABLESPACE_NAME); for (FunctionDesc funcDesc : FunctionLoader.findLegacyFunctions()) { catalog.createFunction(funcDesc); } // TPC-H Schema for Complex Queries String [] tpchTables = { "part", "supplier", "partsupp", "nation", "region", "lineitem" }; tpch = new TPCH(); tpch.loadSchemas(); tpch.loadOutSchema(); for (String table : tpchTables) { TableMeta m = CatalogUtil.newTableMeta(BuiltinStorages.TEXT, util.getConfiguration()); TableDesc d = CatalogUtil.newTableDesc( IdentifierUtil.buildFQName(DEFAULT_DATABASE_NAME, table), tpch.getSchema(table), m, CommonTestingUtil.getTestDir()); catalog.createTable(d); } sqlAnalyzer = new SQLAnalyzer(); planner = new LogicalPlanner(catalog, TablespaceManager.getInstance()); }
catalog = util.getCatalogService(); catalog.createTablespace(DEFAULT_TABLESPACE_NAME, "hdfs://localhost:1234/warehouse"); catalog.createDatabase(DEFAULT_DATABASE_NAME, DEFAULT_TABLESPACE_NAME);
catalog = util.getCatalogService(); catalog.createTablespace(DEFAULT_TABLESPACE_NAME, testDir.toUri().toString()); catalog.createDatabase(DEFAULT_DATABASE_NAME, DEFAULT_TABLESPACE_NAME); for (FunctionDesc funcDesc : FunctionLoader.findLegacyFunctions()) { catalog.createFunction(funcDesc);
catalog.createDatabase(TajoConstants.DEFAULT_DATABASE_NAME, DEFAULT_TABLESPACE_NAME);
testDir = CommonTestingUtil.getTestDir(TEST_PATH); catalog.createTablespace(DEFAULT_TABLESPACE_NAME, testDir.toUri().toString()); catalog.createDatabase(TajoConstants.DEFAULT_DATABASE_NAME, DEFAULT_TABLESPACE_NAME); conf = util.getConfiguration();
testDir = CommonTestingUtil.getTestDir(TEST_PATH); catalog.createTablespace(DEFAULT_TABLESPACE_NAME, testDir.toUri().toString()); catalog.createDatabase(DEFAULT_DATABASE_NAME, DEFAULT_TABLESPACE_NAME); conf = util.getConfiguration();
catalog = util.getCatalogService(); catalog.createTablespace(DEFAULT_TABLESPACE_NAME, "hdfs://localhost:1234/warehouse"); catalog.createDatabase(DEFAULT_DATABASE_NAME, DEFAULT_TABLESPACE_NAME); for (FunctionDesc funcDesc : FunctionLoader.findLegacyFunctions()) { catalog.createFunction(funcDesc);
testDir = CommonTestingUtil.getTestDir(TEST_PATH); catalog.createTablespace(DEFAULT_TABLESPACE_NAME, testDir.toUri().toString()); catalog.createDatabase(DEFAULT_DATABASE_NAME, DEFAULT_TABLESPACE_NAME); conf = util.getConfiguration();
testDir = CommonTestingUtil.getTestDir(TEST_PATH); catalog.createTablespace(DEFAULT_TABLESPACE_NAME, testDir.toUri().toString()); catalog.createDatabase(DEFAULT_DATABASE_NAME, DEFAULT_TABLESPACE_NAME); conf = util.getConfiguration();
catalog = util.getCatalogService(); catalog.createTablespace(DEFAULT_TABLESPACE_NAME, "hdfs://localhost:1234"); catalog.createDatabase(DEFAULT_DATABASE_NAME, DEFAULT_TABLESPACE_NAME);
Path testDir = CommonTestingUtil.getTestDir(TEST_PATH); catalog.createTablespace(DEFAULT_TABLESPACE_NAME, testDir.toUri().toString()); catalog.createDatabase(TajoConstants.DEFAULT_DATABASE_NAME, DEFAULT_TABLESPACE_NAME); conf = util.getConfiguration();