Skip to content

Commit

Permalink
Merge 6b09d2f into 33a6dc2
Browse files Browse the repository at this point in the history
  • Loading branch information
akashrn5 committed Oct 25, 2018
2 parents 33a6dc2 + 6b09d2f commit a2da2fd
Show file tree
Hide file tree
Showing 40 changed files with 579 additions and 230 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1710,6 +1710,21 @@ private CarbonCommonConstants() {
public static final int CARBON_MINMAX_ALLOWED_BYTE_COUNT_MIN = 10;
public static final int CARBON_MINMAX_ALLOWED_BYTE_COUNT_MAX = 1000;

/**
* Written by detail to be written in carbondata footer for better maintanability
*/
public static final String CARBON_WRITTEN_BY_FOOTER_INFO = "written_by";

/**
* carbondata project version used while writing the carbondata file
*/
public static final String CARBON_WRITTEN_VERSION = "version";

/**
* property to set the appName of who is going to write the carbondata
*/
public static final String CARBON_WRITTEN_BY_APPNAME = "carbon.writtenby.app.name";

//////////////////////////////////////////////////////////////////////////////////////////
// Unused constants and parameters start here
//////////////////////////////////////////////////////////////////////////////////////////
Expand Down
1 change: 1 addition & 0 deletions format/src/main/thrift/carbondata.thrift
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ struct FileFooter3{
4: optional list<BlockletInfo3> blocklet_info_list3; // Information about blocklets of all columns in this file for V3 format
5: optional dictionary.ColumnDictionaryChunk dictionary; // Blocklet local dictionary
6: optional bool is_sort; // True if the data is sorted in this file, it is used for compaction to decide whether to use merge sort or not
7: optional map<string, string> extra_info; // map used to write extra info/metadata to file footer ,like who is writing the file and in which version the file is written etc
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ public class CarbonTableInputFormatTest {
addProperty(CarbonCommonConstants.CARBON_BADRECORDS_LOC, "/tmp/carbon/badrecords");
CarbonProperties.getInstance()
.addProperty(CarbonCommonConstants.CARBON_SYSTEM_FOLDER_LOCATION, "/tmp/carbon/");
CarbonProperties.getInstance()
.addProperty(CarbonCommonConstants.CARBON_WRITTEN_BY_APPNAME, "CarbonTableInputFormatTest");
try {
creator = new StoreCreator(new File("target/store").getAbsolutePath(),
new File("../hadoop/src/test/resources/data.csv").getCanonicalPath());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ public class CarbonTableOutputFormatTest {
addProperty(CarbonCommonConstants.CARBON_BADRECORDS_LOC, "/tmp/carbon/badrecords");
CarbonProperties.getInstance()
.addProperty(CarbonCommonConstants.CARBON_SYSTEM_FOLDER_LOCATION, "/tmp/carbon/");
CarbonProperties.getInstance()
.addProperty(CarbonCommonConstants.CARBON_WRITTEN_BY_APPNAME, "CarbonTableOutputFormatTest");
try {
carbonLoadModel = new StoreCreator(new File("target/store").getAbsolutePath(),
new File("../hadoop/src/test/resources/data.csv").getCanonicalPath()).createTableAndLoadModel();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -534,6 +534,8 @@ private void populateCarbonProperties() {
config.getEnableUnsafeColumnPage());
addProperty(CarbonCommonConstants.ENABLE_UNSAFE_SORT, config.getEnableUnsafeSort());
addProperty(CarbonCommonConstants.ENABLE_QUERY_STATISTICS, config.getEnableQueryStatistics());
// TODO: Support configurable
addProperty(CarbonCommonConstants.CARBON_WRITTEN_BY_APPNAME, "Presto_Server");
}

private void setS3Properties() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ class PrestoAllDataTypeTest extends FunSuiteLike with BeforeAndAfterAll {
import org.apache.carbondata.presto.util.CarbonDataStoreCreator
CarbonProperties.getInstance().addProperty(CarbonCommonConstants.CARBON_SYSTEM_FOLDER_LOCATION,
systemPath)
CarbonProperties.getInstance().addProperty(CarbonCommonConstants.CARBON_WRITTEN_BY_APPNAME,
"Presto")
CarbonDataStoreCreator
.createCarbonStore(storePath,
s"$rootPath/integration/presto/src/test/resources/alldatatype.csv")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class TestCarbonFileInputFormatWithExternalCarbonTable extends QueryTest with Be
val builder = CarbonWriter.builder()
val writer =
builder.outputPath(writerPath + "/Fact/Part0/Segment_null")
.withCsvInput(Schema.parseJson(schema)).build()
.withCsvInput(Schema.parseJson(schema)).writtenBy("TestCarbonFileInputFormatWithExternalCarbonTable").build()

var i = 0
while (i < 100) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,13 +139,13 @@ class TestNonTransactionalCarbonTable extends QueryTest with BeforeAndAfterAll {
.sortBy(sortColumns.toArray)
.uniqueIdentifier(
System.currentTimeMillis).withBlockSize(2).withLoadOptions(options)
.withCsvInput(Schema.parseJson(schema)).build()
.withCsvInput(Schema.parseJson(schema)).writtenBy("TestNonTransactionalCarbonTable").build()
} else {
builder.outputPath(writerPath)
.sortBy(sortColumns.toArray)
.uniqueIdentifier(
System.currentTimeMillis).withBlockSize(2)
.withCsvInput(Schema.parseJson(schema)).build()
.withCsvInput(Schema.parseJson(schema)).writtenBy("TestNonTransactionalCarbonTable").build()
}
var i = 0
while (i < rows) {
Expand Down Expand Up @@ -180,7 +180,7 @@ class TestNonTransactionalCarbonTable extends QueryTest with BeforeAndAfterAll {
val writer =
builder.outputPath(writerPath)
.uniqueIdentifier(System.currentTimeMillis()).withBlockSize(2).sortBy(sortColumns)
.withCsvInput(new Schema(fields)).build()
.withCsvInput(new Schema(fields)).writtenBy("TestNonTransactionalCarbonTable").build()
var i = 0
while (i < rows) {
writer.write(Array[String]("true", String.valueOf(i), String.valueOf(i.toDouble / 2)))
Expand Down Expand Up @@ -211,7 +211,7 @@ class TestNonTransactionalCarbonTable extends QueryTest with BeforeAndAfterAll {
.sortBy(sortColumns.toArray)
.uniqueIdentifier(
123).withBlockSize(2)
.withCsvInput(Schema.parseJson(schema)).build()
.withCsvInput(Schema.parseJson(schema)).writtenBy("TestNonTransactionalCarbonTable").build()
var i = 0
while (i < rows) {
writer.write(Array[String]("robot" + i, String.valueOf(i), String.valueOf(i.toDouble / 2)))
Expand Down Expand Up @@ -389,6 +389,10 @@ class TestNonTransactionalCarbonTable extends QueryTest with BeforeAndAfterAll {
|'carbondata' LOCATION
|'$writerPath' """.stripMargin)

val output = sql("show summary for table sdkOutputTable options('command'='-cmd,summary,-p,-a,-v,-c,age')").collect()

assert(output.toList.contains(Row("written_by Version ")))

checkExistence(sql("describe formatted sdkOutputTable"), true, "age,name")

checkExistence(sql("describe formatted sdkOutputTable"), true, writerPath)
Expand Down Expand Up @@ -985,7 +989,7 @@ class TestNonTransactionalCarbonTable extends QueryTest with BeforeAndAfterAll {
val builder: CarbonWriterBuilder = CarbonWriter.builder.outputPath(writerPath)
.withLoadOptions(options)

val writer: CarbonWriter = builder.withCsvInput(new Schema(fields)).build()
val writer: CarbonWriter = builder.withCsvInput(new Schema(fields)).writtenBy("TestNonTransactionalCarbonTable").build()
writer.write(Array("babu","1","02-01-2002","02-01-2002 01:01:00"))
writer.close()

Expand Down Expand Up @@ -1110,7 +1114,7 @@ class TestNonTransactionalCarbonTable extends QueryTest with BeforeAndAfterAll {
try {
val writer = CarbonWriter.builder
.outputPath(writerPath)
.uniqueIdentifier(System.currentTimeMillis()).withAvroInput(nn).build()
.uniqueIdentifier(System.currentTimeMillis()).withAvroInput(nn).writtenBy("TestNonTransactionalCarbonTable").build()
var i = 0
while (i < rows) {
writer.write(record)
Expand Down Expand Up @@ -2084,7 +2088,7 @@ class TestNonTransactionalCarbonTable extends QueryTest with BeforeAndAfterAll {

assert(intercept[RuntimeException] {
val writer = CarbonWriter.builder.sortBy(Array("name", "id"))
.outputPath(writerPath).withAvroInput(nn).build()
.outputPath(writerPath).withAvroInput(nn).writtenBy("TestNonTransactionalCarbonTable").build()
writer.write(record)
writer.close()
}.getMessage.toLowerCase.contains("column: name specified in sort columns"))
Expand Down Expand Up @@ -2124,7 +2128,7 @@ class TestNonTransactionalCarbonTable extends QueryTest with BeforeAndAfterAll {
val record = testUtil.jsonToAvro(json1, schema1)

val writer = CarbonWriter.builder
.outputPath(writerPath).withAvroInput(nn).build()
.outputPath(writerPath).withAvroInput(nn).writtenBy("TestNonTransactionalCarbonTable").build()
writer.write(record)
writer.close()
}
Expand Down Expand Up @@ -2162,7 +2166,7 @@ class TestNonTransactionalCarbonTable extends QueryTest with BeforeAndAfterAll {
val record = testUtil.jsonToAvro(json1, schema1)

val writer = CarbonWriter.builder.sortBy(Array("id"))
.outputPath(writerPath).withAvroInput(nn).build()
.outputPath(writerPath).withAvroInput(nn).writtenBy("TestNonTransactionalCarbonTable").build()
writer.write(record)
writer.close()
}
Expand Down Expand Up @@ -2206,7 +2210,7 @@ class TestNonTransactionalCarbonTable extends QueryTest with BeforeAndAfterAll {
val record = testUtil.jsonToAvro(json1, schema)

val writer = CarbonWriter.builder
.outputPath(writerPath).withAvroInput(nn).build()
.outputPath(writerPath).withAvroInput(nn).writtenBy("TestNonTransactionalCarbonTable").build()
writer.write(record)
writer.close()
}
Expand Down Expand Up @@ -2246,7 +2250,7 @@ class TestNonTransactionalCarbonTable extends QueryTest with BeforeAndAfterAll {
val record = testUtil.jsonToAvro(json1, schema1)

val writer = CarbonWriter.builder
.outputPath(writerPath).withAvroInput(nn).build()
.outputPath(writerPath).withAvroInput(nn).writtenBy("TestNonTransactionalCarbonTable").build()
writer.write(record)
writer.close()
sql(
Expand Down Expand Up @@ -2292,7 +2296,7 @@ class TestNonTransactionalCarbonTable extends QueryTest with BeforeAndAfterAll {
val record = testUtil.jsonToAvro(json1, schema1)

val writer = CarbonWriter.builder
.outputPath(writerPath).withAvroInput(nn).build()
.outputPath(writerPath).withAvroInput(nn).writtenBy("TestNonTransactionalCarbonTable").build()
writer.write(record)
writer.close()
sql(
Expand Down Expand Up @@ -2339,7 +2343,7 @@ class TestNonTransactionalCarbonTable extends QueryTest with BeforeAndAfterAll {


val writer = CarbonWriter.builder
.outputPath(writerPath).withAvroInput(nn).build()
.outputPath(writerPath).withAvroInput(nn).writtenBy("TestNonTransactionalCarbonTable").build()
writer.write(record)
writer.close()
sql(
Expand All @@ -2359,7 +2363,7 @@ class TestNonTransactionalCarbonTable extends QueryTest with BeforeAndAfterAll {
val writer: CarbonWriter = CarbonWriter.builder
.outputPath(writerPath)
.withTableProperties(options)
.withCsvInput(new Schema(fields)).build()
.withCsvInput(new Schema(fields)).writtenBy("TestNonTransactionalCarbonTable").build()
writer.write(Array("carbon", "1"))
writer.write(Array("hydrogen", "10"))
writer.write(Array("boron", "4"))
Expand All @@ -2377,7 +2381,7 @@ class TestNonTransactionalCarbonTable extends QueryTest with BeforeAndAfterAll {
// write local sort data
val writer1: CarbonWriter = CarbonWriter.builder
.outputPath(writerPath)
.withCsvInput(new Schema(fields)).build()
.withCsvInput(new Schema(fields)).writtenBy("TestNonTransactionalCarbonTable").build()
writer1.write(Array("carbon", "1"))
writer1.write(Array("hydrogen", "10"))
writer1.write(Array("boron", "4"))
Expand All @@ -2393,7 +2397,7 @@ class TestNonTransactionalCarbonTable extends QueryTest with BeforeAndAfterAll {
FileUtils.deleteDirectory(new File(writerPath))
val builder = CarbonWriter.builder
.sortBy(Array[String]("name")).withBlockSize(12).enableLocalDictionary(true)
.uniqueIdentifier(System.currentTimeMillis).taskNo(System.nanoTime).outputPath(writerPath)
.uniqueIdentifier(System.currentTimeMillis).taskNo(System.nanoTime).outputPath(writerPath).writtenBy("TestNonTransactionalCarbonTable")
generateCarbonData(builder)
assert(FileFactory.getCarbonFile(writerPath).exists())
assert(testUtil.checkForLocalDictionary(testUtil.getDimRawChunk(0,writerPath)))
Expand All @@ -2418,7 +2422,7 @@ class TestNonTransactionalCarbonTable extends QueryTest with BeforeAndAfterAll {
"local_dictionary_enable" -> "true").asJava
val builder = CarbonWriter.builder
.withTableProperties(tablePropertiesMap)
.uniqueIdentifier(System.currentTimeMillis).taskNo(System.nanoTime).outputPath(writerPath)
.uniqueIdentifier(System.currentTimeMillis).taskNo(System.nanoTime).outputPath(writerPath).writtenBy("TestNonTransactionalCarbonTable")
generateCarbonData(builder)
assert(FileFactory.getCarbonFile(writerPath).exists())
assert(testUtil.checkForLocalDictionary(testUtil.getDimRawChunk(0,writerPath)))
Expand All @@ -2439,7 +2443,7 @@ class TestNonTransactionalCarbonTable extends QueryTest with BeforeAndAfterAll {
val builder = CarbonWriter.builder
.sortBy(Array[String]("name")).withBlockSize(12).enableLocalDictionary(true)
.localDictionaryThreshold(5)
.uniqueIdentifier(System.currentTimeMillis).taskNo(System.nanoTime).outputPath(writerPath)
.uniqueIdentifier(System.currentTimeMillis).taskNo(System.nanoTime).outputPath(writerPath).writtenBy("TestNonTransactionalCarbonTable")
generateCarbonData(builder)
assert(FileFactory.getCarbonFile(writerPath).exists())
assert(!testUtil.checkForLocalDictionary(testUtil.getDimRawChunk(0,writerPath)))
Expand All @@ -2460,7 +2464,7 @@ class TestNonTransactionalCarbonTable extends QueryTest with BeforeAndAfterAll {
val builder = CarbonWriter.builder
.sortBy(Array[String]("name")).withBlockSize(12).enableLocalDictionary(true)
.localDictionaryThreshold(200)
.uniqueIdentifier(System.currentTimeMillis).taskNo(System.nanoTime).outputPath(writerPath)
.uniqueIdentifier(System.currentTimeMillis).taskNo(System.nanoTime).outputPath(writerPath).writtenBy("TestNonTransactionalCarbonTable")
generateCarbonData(builder)
assert(FileFactory.getCarbonFile(writerPath).exists())
assert(testUtil.checkForLocalDictionary(testUtil.getDimRawChunk(0,writerPath)))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ class TestNonTransactionalCarbonTableJsonWriter extends QueryTest with BeforeAnd
.outputPath(writerPath)
.uniqueIdentifier(System.currentTimeMillis())
.withLoadOptions(options)
.withJsonInput(carbonSchema).build()
.withJsonInput(carbonSchema).writtenBy("TestNonTransactionalCarbonTableJsonWriter").build()
writer.write(jsonRow)
writer.close()
}
Expand Down
Loading

0 comments on commit a2da2fd

Please sign in to comment.