-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes #35.
- Loading branch information
Showing
10 changed files
with
150 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
src/it/scala/com/exasol/cloudetl/FilesMetadataReaderIT.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package com.exasol.cloudetl | ||
|
||
import java.nio.file.Files | ||
import java.nio.file.Path | ||
|
||
import com.exasol.matcher.ResultSetStructureMatcher.table | ||
|
||
import org.apache.hadoop.fs.{Path => HPath} | ||
import org.hamcrest.MatcherAssert.assertThat | ||
import org.scalatest.BeforeAndAfterEach | ||
|
||
class FilesMetadataReaderIT | ||
extends BaseIntegrationTest | ||
with BeforeAndAfterEach | ||
with TestFileManager { | ||
|
||
val schemaName = "DATA_SCHEMA" | ||
val tableName = "DATA_TABLE" | ||
val bucketName: String = "databucket" | ||
var outputDirectory: Path = _ | ||
|
||
override final def beforeAll(): Unit = { | ||
startContainers() | ||
prepareExasolDatabase(schemaName) | ||
prepareS3Client() | ||
} | ||
|
||
override final def beforeEach(): Unit = | ||
outputDirectory = createTemporaryFolder(s"data-files-") | ||
|
||
override final def afterEach(): Unit = | ||
deletePathFiles(outputDirectory) | ||
|
||
def getTableName(): String = s""""$schemaName"."$tableName"""" | ||
|
||
test("filters hidden and metadata files") { | ||
val hidden = Seq("_SUCCESS", ".METADATA").map(outputDirectory.resolve(_)) | ||
hidden.foreach { case f => Files.createFile(f) } | ||
|
||
val file1 = new HPath(outputDirectory.toUri.toString, "_SUCCESS") | ||
uploadFileToS3(bucketName, file1) | ||
val file2 = new HPath(outputDirectory.toUri.toString, ".METADATA") | ||
uploadFileToS3(bucketName, file2) | ||
|
||
val exasolTable = schema | ||
.createTableBuilder(tableName) | ||
.column("COLUMN", "VARCHAR(5)") | ||
.build() | ||
importIntoExasol(schemaName, exasolTable, bucketName, "*", "parquet") | ||
|
||
val resultSet = executeQuery(s"SELECT * FROM ${getTableName()}") | ||
assertThat(resultSet, table("VARCHAR").matches()) | ||
resultSet.close() | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
src/main/scala/com/exasol/cloudetl/filesystem/HiddenFilesFilter.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package com.exasol.cloudetl.filesystem | ||
|
||
import org.apache.hadoop.fs.Path | ||
import org.apache.hadoop.fs.PathFilter | ||
|
||
object HiddenFilesFilter extends PathFilter { | ||
|
||
private[this] val PREFIX_DOT = "." | ||
private[this] val PREFIX_UNDERSCORE = "_" | ||
|
||
override def accept(p: Path): Boolean = { | ||
val name = p.getName() | ||
!name.startsWith(PREFIX_DOT) && !name.startsWith(PREFIX_UNDERSCORE) | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters