@Test public void toDottedPathWithCommonPrefix() throws Exception { assertEquals("d", PathUtils.toDottedPath(new Path("/a/b/c"), new Path("/a/b/c/d"))); assertEquals("b.c.d", PathUtils.toDottedPath(new Path("/a"), new Path("/a/b/c/d"))); assertEquals("a.b.c.d", PathUtils.toDottedPath(new Path("/"), new Path("/a/b/c/d"))); assertEquals("c.d.\"e.json\"", PathUtils.toDottedPath(new Path("/a/b/"), new Path("/a/b/c/d/e.json"))); }
@Test public void testFSPathToSchemaPath() throws Exception { assertEquals("a.b.c", PathUtils.toDottedPath(new Path("/a/b/c"))); assertEquals("a.b.c", PathUtils.toDottedPath(new Path("a/b/c"))); assertEquals("a.b.\"c.json\"", PathUtils.toDottedPath(new Path("/a/b/c.json"))); assertEquals("\"c.json\"", PathUtils.toDottedPath(new Path("c.json"))); assertEquals("\"c.json\"", PathUtils.toDottedPath(new Path("/c.json"))); assertEquals("c", PathUtils.toDottedPath(new Path("/c"))); }
@Test public void toDottedPathWithInvalidPrefix() throws Exception { try { PathUtils.toDottedPath(new Path("/p/q/"), new Path("/a/b/c/d/e.json")); fail("constructing relative path of child /a/b/c/d/e.json with parent /p/q should fail"); } catch (IOException e) { } }
@POST @Path("file_preview_unsaved/{path: .*}") @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) public JobDataFragment previewFormatSettingsStaging(FileFormat fileFormat, @PathParam("path") String path) throws FileNotFoundException, SourceNotFoundException { FilePath filePath = FilePath.fromURLPath(homeName, path); logger.debug("filePath: " + filePath.toPathString()); // use file's location directly to query file String fileLocation = PathUtils.toDottedPath(new org.apache.hadoop.fs.Path(fileFormat.getLocation())); SqlQuery query = new SqlQuery(format("select * from table(%s.%s (%s)) limit 500", SqlUtils.quoteIdentifier(HomeFileSystemStoragePlugin.HOME_PLUGIN_NAME), fileLocation, fileFormat.toTableOptions()), securityContext.getUserPrincipal().getName()); JobUI job = new JobUI(jobsService.submitJob(JobRequest.newBuilder() .setSqlQuery(query) .setQueryType(QueryType.UI_INITIAL_PREVIEW) .build(), NoOpJobStatusListener.INSTANCE)); return job.getData().truncate(500); }
String fileLocation = PathUtils.toDottedPath(new org.apache.hadoop.fs.Path(file1StagedFormat.getLocation())); SqlQuery query = new SqlQuery(format("select * from table(%s.%s (%s)) limit 500", SqlUtils.quoteIdentifier(HomeFileSystemStoragePlugin.HOME_PLUGIN_NAME), fileLocation, file1StagedFormat.toTableOptions()), SampleDataPopulator.DEFAULT_USER_NAME);