Compare commits

..

2 Commits

Author SHA1 Message Date
Raghunandan 43db6c5dae [maven-release-plugin] prepare for next development iteration 2021-06-30 11:36:32 +05:30
Raghunandan d0764e72f8 [maven-release-plugin] prepare release 1.3.0 2021-06-30 11:36:32 +05:30
2461 changed files with 23520 additions and 206850 deletions

3
.gitignore vendored
View File

@ -1,7 +1,6 @@
*.iml
*.ipr
*.iws
*.icloud
target/
/var
/*/var/
@ -28,4 +27,4 @@ node_modules
*/*.iml
*/.idea
*/.gitignore
*/dependency-reduced-pom.xml
*/dependency-reduced-pom.xml

1
OWNERS
View File

@ -7,4 +7,3 @@ approvers:
- farhan3
- fbird2020
- lizheng920625
- giteezhangjingfang

View File

@ -1,6 +1,6 @@
#!/usr/bin/env bash
# Copyright (C) 2020-2021. Huawei Technologies Co., Ltd. All rights reserved.
# Copyright (C) 2020. Huawei Technologies Co., Ltd. All rights reserved.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at

View File

@ -22,7 +22,7 @@
<parent>
<groupId>io.hetu.core</groupId>
<artifactId>presto-root</artifactId>
<version>1.7.0-SNAPSHOT</version>
<version>1.3.1-SNAPSHOT</version>
</parent>
<artifactId>hetu-carbondata</artifactId>
@ -371,7 +371,7 @@
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-compress</artifactId>
<version>1.21</version>
<version>1.19</version>
<scope>runtime</scope>
</dependency>
<dependency>

View File

@ -108,7 +108,8 @@ public class CarbondataAutoVacuumThread
AutoVacuumScanTask(SemiTransactionalHiveMetastore metastore)
{
this(metastore, null);
this.metastore = metastore;
this.schemaName = null;
}
AutoVacuumScanTask(SemiTransactionalHiveMetastore metastore, String schemaName)
@ -232,6 +233,7 @@ public class CarbondataAutoVacuumThread
private void submitTaskScanning(CarbondataAutoVacuumThread instanceAutoVacuum, SemiTransactionalHiveMetastore metastore)
{
//trigger task to do scanning of tables
//instanceAutoVacuum.executorService.submit(new AutoVacuumScanTask(metastore));
if (enableTracingCleanupTask) {
queuedTasks.add(instanceAutoVacuum.executorService.submit(new AutoVacuumScanTask(metastore)));
}

View File

@ -73,17 +73,16 @@ public class CarbondataColumnVectorWrapper
@Override
public void putShorts(int rowId, int count, short value)
{
int inputRowId = rowId;
if (filteredRowsExist) {
for (int i = 0; i < count; i++) {
if (!filteredRows[inputRowId]) {
if (!filteredRows[rowId]) {
columnVector.putShort(counter++, value);
}
inputRowId++;
rowId++;
}
}
else {
columnVector.putShorts(inputRowId, count, value);
columnVector.putShorts(rowId, count, value);
}
}
@ -98,17 +97,16 @@ public class CarbondataColumnVectorWrapper
@Override
public void putInts(int rowId, int count, int value)
{
int inputRowId = rowId;
if (filteredRowsExist) {
for (int i = 0; i < count; i++) {
if (!filteredRows[inputRowId]) {
if (!filteredRows[rowId]) {
columnVector.putInt(counter++, value);
}
inputRowId++;
rowId++;
}
}
else {
columnVector.putInts(inputRowId, count, value);
columnVector.putInts(rowId, count, value);
}
}
@ -123,17 +121,16 @@ public class CarbondataColumnVectorWrapper
@Override
public void putLongs(int rowId, int count, long value)
{
int inputRowId = rowId;
if (filteredRowsExist) {
for (int i = 0; i < count; i++) {
if (!filteredRows[inputRowId]) {
if (!filteredRows[rowId]) {
columnVector.putLong(counter++, value);
}
inputRowId++;
rowId++;
}
}
else {
columnVector.putLongs(inputRowId, count, value);
columnVector.putLongs(rowId, count, value);
}
}
@ -148,12 +145,11 @@ public class CarbondataColumnVectorWrapper
@Override
public void putDecimals(int rowId, int count, BigDecimal value, int precision)
{
int inputRowId = rowId;
for (int i = 0; i < count; i++) {
if (!filteredRows[inputRowId]) {
if (!filteredRows[rowId]) {
columnVector.putDecimal(counter++, value, precision);
}
inputRowId++;
rowId++;
}
}
@ -168,17 +164,16 @@ public class CarbondataColumnVectorWrapper
@Override
public void putDoubles(int rowId, int count, double value)
{
int inputRowId = rowId;
if (filteredRowsExist) {
for (int i = 0; i < count; i++) {
if (!filteredRows[inputRowId]) {
if (!filteredRows[rowId]) {
columnVector.putDouble(counter++, value);
}
inputRowId++;
rowId++;
}
}
else {
columnVector.putDoubles(inputRowId, count, value);
columnVector.putDoubles(rowId, count, value);
}
}
@ -201,12 +196,11 @@ public class CarbondataColumnVectorWrapper
@Override
public void putByteArray(int rowId, int count, byte[] value)
{
int inputRowId = rowId;
for (int i = 0; i < count; i++) {
if (!filteredRows[inputRowId]) {
if (!filteredRows[rowId]) {
columnVector.putByteArray(counter++, value);
}
inputRowId++;
rowId++;
}
}
@ -229,17 +223,16 @@ public class CarbondataColumnVectorWrapper
@Override
public void putNulls(int rowId, int count)
{
int inputRowId = rowId;
if (filteredRowsExist) {
for (int i = 0; i < count; i++) {
if (!filteredRows[inputRowId]) {
if (!filteredRows[rowId]) {
columnVector.putNull(counter++);
}
inputRowId++;
rowId++;
}
}
else {
columnVector.putNulls(inputRowId, count);
columnVector.putNulls(rowId, count);
}
}
@ -326,72 +319,66 @@ public class CarbondataColumnVectorWrapper
@Override
public void putFloats(int rowId, int count, float[] src, int srcIndex)
{
int inputRowId = rowId;
for (int i = srcIndex; i < count; i++) {
if (!filteredRows[inputRowId]) {
if (!filteredRows[rowId]) {
columnVector.putFloat(counter++, src[i]);
}
inputRowId++;
rowId++;
}
}
@Override
public void putShorts(int rowId, int count, short[] src, int srcIndex)
{
int inputRowId = rowId;
for (int i = srcIndex; i < count; i++) {
if (!filteredRows[inputRowId]) {
if (!filteredRows[rowId]) {
columnVector.putShort(counter++, src[i]);
}
inputRowId++;
rowId++;
}
}
@Override
public void putInts(int rowId, int count, int[] src, int srcIndex)
{
int inputRowId = rowId;
for (int i = srcIndex; i < count; i++) {
if (!filteredRows[inputRowId]) {
if (!filteredRows[rowId]) {
columnVector.putInt(counter++, src[i]);
}
inputRowId++;
rowId++;
}
}
@Override
public void putLongs(int rowId, int count, long[] src, int srcIndex)
{
int inputRowId = rowId;
for (int i = srcIndex; i < count; i++) {
if (!filteredRows[inputRowId]) {
if (!filteredRows[rowId]) {
columnVector.putLong(counter++, src[i]);
}
inputRowId++;
rowId++;
}
}
@Override
public void putDoubles(int rowId, int count, double[] src, int srcIndex)
{
int inputRowId = rowId;
for (int i = srcIndex; i < count; i++) {
if (!filteredRows[inputRowId]) {
if (!filteredRows[rowId]) {
columnVector.putDouble(counter++, src[i]);
}
inputRowId++;
rowId++;
}
}
@Override
public void putBytes(int rowId, int count, byte[] src, int srcIndex)
{
int inputRowId = rowId;
for (int i = srcIndex; i < count; i++) {
if (!filteredRows[inputRowId]) {
if (!filteredRows[rowId]) {
columnVector.putByte(counter++, src[i]);
}
inputRowId++;
rowId++;
}
}

View File

@ -127,16 +127,15 @@ public class CarbondataFileWriter
private boolean isInitDone;
private boolean isCommitDone;
public CarbondataFileWriter(Path paramOutPutPath, List<String> inputColumnNames, Properties properties,
public CarbondataFileWriter(Path outPutPath, List<String> inputColumnNames, Properties properties,
JobConf configuration, TypeManager typeManager, Optional<AcidOutputFormat.Options> acidOptions,
Optional<HiveACIDWriteType> acidWriteType, OptionalInt taskId) throws SerDeException
{
Path localOutPutPath = paramOutPutPath;
this.outPutPath = requireNonNull(localOutPutPath, "path is null");
this.outPutPath = requireNonNull(outPutPath, "path is null");
// in table creation this can be null
if (null != properties.getProperty("location")) {
this.outPutPath = new Path(properties.getProperty("location"));
localOutPutPath = new Path(properties.getProperty("location"));
outPutPath = new Path(properties.getProperty("location"));
}
this.configuration = requireNonNull(configuration, "conf is null");
this.properties = requireNonNull(properties, "Properties is null");
@ -212,7 +211,7 @@ public class CarbondataFileWriter
Object writer =
Class.forName(MapredCarbonOutputFormat.class.getName()).getConstructor().newInstance();
recordWriter = ((MapredCarbonOutputFormat<?>) writer)
.getHiveRecordWriter(this.configuration, localOutPutPath, Text.class, compress,
.getHiveRecordWriter(this.configuration, outPutPath, Text.class, compress,
properties, Reporter.NULL);
}
@ -227,25 +226,25 @@ public class CarbondataFileWriter
private FileSinkOperator.RecordWriter getHiveWriter(String segmentId, long taskNo) throws Exception
{
Path finalOutPutPath = this.outPutPath;
Properties finalProperties = this.properties;
JobConf finalConfiguration = this.configuration;
boolean compress = HiveConf.getBoolVar(finalConfiguration, COMPRESSRESULT);
Path outPutPath = this.outPutPath;
Properties properties = this.properties;
JobConf configuration = this.configuration;
boolean compress = HiveConf.getBoolVar(configuration, COMPRESSRESULT);
CarbonLoadModel carbonLoadModel = HiveCarbonUtil.getCarbonLoadModel(finalProperties, finalConfiguration);
CarbonLoadModel carbonLoadModel = HiveCarbonUtil.getCarbonLoadModel(properties, configuration);
carbonLoadModel.setSegmentId(segmentId);
carbonLoadModel.setTaskNo(String.valueOf(taskNo));
carbonLoadModel.setFactTimeStamp(Long.parseLong(txnTimeStamp));
carbonLoadModel.setBadRecordsAction(TableOptionConstant.BAD_RECORDS_ACTION.getName() + ",force");
CarbonTableOutputFormat.setLoadModel(finalConfiguration, carbonLoadModel);
CarbonTableOutputFormat.setLoadModel(configuration, carbonLoadModel);
this.configuration.set(CarbondataConstants.TaskId, getTaskAttemptId(String.valueOf(taskNo)));
Object writer =
Class.forName(MapredCarbonOutputFormat.class.getName()).getConstructor().newInstance();
return ((MapredCarbonOutputFormat<?>) writer)
.getHiveRecordWriter(finalConfiguration, finalOutPutPath, Text.class, compress,
finalProperties, Reporter.NULL);
.getHiveRecordWriter(configuration, outPutPath, Text.class, compress,
properties, Reporter.NULL);
}
@Override
@ -286,7 +285,7 @@ public class CarbondataFileWriter
public void appendRow(Page dataPage, int position)
{
FileSinkOperator.RecordWriter finalRecordWriter = null;
FileSinkOperator.RecordWriter recordWriter = null;
if (HiveACIDWriteType.isUpdateOrDelete(acidWriteType)) {
try {
DeleteDeltaBlockDetails deleteDeltaBlockDetails = null;
@ -335,7 +334,7 @@ public class CarbondataFileWriter
return;
}
finalRecordWriter = segmentRecordWriterMap.computeIfAbsent(segmentId, v ->
recordWriter = segmentRecordWriterMap.computeIfAbsent(segmentId, v ->
{
try {
return getHiveWriter(segmentId, CarbonUpdateUtil.getLatestTaskIdForSegment(new Segment(segmentId), tablePath) + 1);
@ -352,7 +351,7 @@ public class CarbondataFileWriter
}
}
else {
finalRecordWriter = this.recordWriter;
recordWriter = this.recordWriter;
}
for (int field = 0; field < fieldCount; field++) {
@ -366,8 +365,8 @@ public class CarbondataFileWriter
}
try {
if (finalRecordWriter != null) {
finalRecordWriter.write(serDe.serialize(row, tableInspector));
if (recordWriter != null) {
recordWriter.write(serDe.serialize(row, tableInspector));
}
}
catch (SerDeException | IOException e) {

View File

@ -48,7 +48,6 @@ public class CarbondataHandleResolver
return CarbonDeleteAsInsertTableHandle.class;
}
@Override
public Class<? extends ConnectorOutputTableHandle> getOutputTableHandleClass()
{
return CarbondataOutputTableHandle.class;

View File

@ -317,11 +317,11 @@ public class CarbondataHetuFilterUtil
if (rawData instanceof Slice) {
String value = ((Slice) rawData).toStringUtf8();
if (type.getTypeInfo() instanceof CharTypeInfo) {
StringBuilder padding = new StringBuilder();
String padding = "";
int paddedLength = ((CharTypeInfo) type.getTypeInfo()).getLength();
int truncatedLength = value.length();
for (int i = 0; i < paddedLength - truncatedLength; i++) {
padding.append(" ");
padding += " ";
}
return value + padding;
}

View File

@ -103,6 +103,7 @@ public class CarbondataHetuOutputFormat<T>
OutputCommitter carbonOutputCommitter = super.getOutputCommitter(context);
JobContextImpl jobContext = new JobContextImpl(jc, new JobID());
carbonOutputCommitter.setupJob(jobContext);
CarbonLoadModel updatedCarbonLoadModel = CarbonTableOutputFormat.getLoadModel(jc);
org.apache.hadoop.mapreduce.RecordWriter re = super.getRecordWriter(context);
return new FileSinkOperator.RecordWriter()
{

View File

@ -80,6 +80,8 @@ public class CarbondataLocationService
{
// TODO: check and make it compatible for cloud scenario
HdfsEnvironment.HdfsContext context =
new HdfsEnvironment.HdfsContext(session, table.getDatabaseName(), table.getTableName());
Path targetPath = new Path(table.getStorage().getLocation());
return new LocationHandle(targetPath, targetPath, true,

View File

@ -92,28 +92,15 @@ import org.apache.carbondata.common.logging.LogServiceFactory;
import org.apache.carbondata.core.constants.CarbonCommonConstants;
import org.apache.carbondata.core.datastore.filesystem.CarbonFile;
import org.apache.carbondata.core.datastore.impl.FileFactory;
import org.apache.carbondata.core.features.TableOperation;
import org.apache.carbondata.core.fileoperations.FileWriteOperation;
import org.apache.carbondata.core.index.Segment;
import org.apache.carbondata.core.locks.CarbonLockFactory;
import org.apache.carbondata.core.locks.CarbonLockUtil;
import org.apache.carbondata.core.locks.ICarbonLock;
import org.apache.carbondata.core.locks.LockUsage;
import org.apache.carbondata.core.metadata.AbsoluteTableIdentifier;
import org.apache.carbondata.core.metadata.CarbonMetadata;
import org.apache.carbondata.core.metadata.CarbonTableIdentifier;
import org.apache.carbondata.core.metadata.SegmentFileStore;
import org.apache.carbondata.core.metadata.converter.SchemaConverter;
import org.apache.carbondata.core.metadata.converter.ThriftWrapperSchemaConverterImpl;
import org.apache.carbondata.core.metadata.datatype.DataTypes;
import org.apache.carbondata.core.metadata.datatype.StructField;
import org.apache.carbondata.core.metadata.schema.PartitionInfo;
import org.apache.carbondata.core.metadata.schema.SchemaEvolutionEntry;
import org.apache.carbondata.core.metadata.schema.table.CarbonTable;
import org.apache.carbondata.core.metadata.schema.table.TableInfo;
import org.apache.carbondata.core.metadata.schema.table.TableSchema;
import org.apache.carbondata.core.metadata.schema.table.TableSchemaBuilder;
import org.apache.carbondata.core.metadata.schema.table.column.ColumnSchema;
import org.apache.carbondata.core.mutate.CarbonUpdateUtil;
import org.apache.carbondata.core.mutate.SegmentUpdateDetails;
import org.apache.carbondata.core.mutate.data.BlockMappingVO;
@ -126,7 +113,6 @@ import org.apache.carbondata.core.util.CarbonUtil;
import org.apache.carbondata.core.util.ObjectSerializationUtil;
import org.apache.carbondata.core.util.ThreadLocalSessionInfo;
import org.apache.carbondata.core.util.path.CarbonTablePath;
import org.apache.carbondata.core.writer.ThriftWriter;
import org.apache.carbondata.hadoop.api.CarbonOutputCommitter;
import org.apache.carbondata.hadoop.api.CarbonTableInputFormat;
import org.apache.carbondata.hadoop.api.CarbonTableOutputFormat;
@ -161,16 +147,13 @@ import java.io.File;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Comparator;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.NoSuchElementException;
import java.util.Optional;
import java.util.Properties;
import java.util.Set;
@ -237,10 +220,6 @@ public class CarbondataMetadata
private List<SegmentUpdateDetails> blockUpdateDetailsList;
private State currentState = State.OTHER;
private CarbonLoadModel carbonLoadModel;
private AbsoluteTableIdentifier absoluteTableIdentifier;
private TableInfo tableInfo;
private SchemaTableName schemaTableName;
private String user;
private Optional<String> tableStorageLocation;
private String carbondataTableStore;
@ -265,9 +244,6 @@ public class CarbondataMetadata
CREATE_TABLE_AS,
DROP_TABLE,
OTHER,
ADD_COLUMN,
DROP_COLUMN,
RENAME_COLUMN
}
public CarbondataMetadata(SemiTransactionalHiveMetastore metastore,
@ -306,13 +282,13 @@ public class CarbondataMetadata
private void setupCommitWriter(Properties hiveSchema, Path outputPath, Configuration initialConfiguration, boolean isOverwrite) throws PrestoException
{
CarbonLoadModel finalCarbonLoadModel;
CarbonLoadModel carbonLoadModel;
TaskAttemptID taskAttemptID = TaskAttemptID.forName(initialConfiguration.get("mapred.task.id"));
try {
ThreadLocalSessionInfo.setConfigurationToCurrentThread(initialConfiguration);
finalCarbonLoadModel = HiveCarbonUtil.getCarbonLoadModel(hiveSchema, initialConfiguration);
finalCarbonLoadModel.setBadRecordsAction(TableOptionConstant.BAD_RECORDS_ACTION.getName() + ",force");
CarbonTableOutputFormat.setLoadModel(initialConfiguration, finalCarbonLoadModel);
carbonLoadModel = HiveCarbonUtil.getCarbonLoadModel(hiveSchema, initialConfiguration);
carbonLoadModel.setBadRecordsAction(TableOptionConstant.BAD_RECORDS_ACTION.getName() + ",force");
CarbonTableOutputFormat.setLoadModel(initialConfiguration, carbonLoadModel);
}
catch (IOException ex) {
LOG.error("Error while creating carbon load model", ex);
@ -360,13 +336,13 @@ public class CarbondataMetadata
this.user = session.getUser();
return hdfsEnvironment.doAs(user, () -> {
SchemaTableName tableName = parent.getSchemaTableName();
Optional<Table> finalTable =
Optional<Table> table =
metastore.getTable(new HiveIdentity(session), tableName.getSchemaName(), tableName.getTableName());
if (finalTable.isPresent() && finalTable.get().getPartitionColumns().size() > 0) {
if (table.isPresent() && table.get().getPartitionColumns().size() > 0) {
throw new PrestoException(NOT_SUPPORTED, "Operations on Partitioned CarbonTables is not supported");
}
this.table = finalTable;
this.table = table;
Path outputPath =
new Path(parent.getLocationHandle().getJsonSerializableTargetPath());
initialConfiguration = ConfigurationUtils.toJobConf(this.hdfsEnvironment
@ -382,7 +358,7 @@ public class CarbondataMetadata
}
/* Create committer object */
setupCommitWriter(finalTable, outputPath, initialConfiguration, isOverwrite);
setupCommitWriter(table, outputPath, initialConfiguration, isOverwrite);
return new CarbondataInsertTableHandle(parent.getSchemaName(),
parent.getTableName(),
@ -416,13 +392,13 @@ public class CarbondataMetadata
currentState = State.UPDATE;
HiveInsertTableHandle parent = super.beginInsert(session, tableHandle);
SchemaTableName tableName = parent.getSchemaTableName();
Optional<Table> finalTable =
Optional<Table> table =
this.metastore.getTable(new HiveIdentity(session), tableName.getSchemaName(), tableName.getTableName());
if (finalTable.isPresent() && finalTable.get().getPartitionColumns().size() > 0) {
if (table.isPresent() && table.get().getPartitionColumns().size() > 0) {
throw new PrestoException(NOT_SUPPORTED, "Operations on Partitioned CarbonTables is not supported");
}
this.table = finalTable;
this.table = table;
this.user = session.getUser();
hdfsEnvironment.doAs(user, () -> {
initialConfiguration = ConfigurationUtils.toJobConf(this.hdfsEnvironment
@ -430,8 +406,8 @@ public class CarbondataMetadata
new HdfsEnvironment.HdfsContext(session, parent.getSchemaName(),
parent.getTableName()),
new Path(parent.getLocationHandle().getJsonSerializableWritePath())));
Properties schema = MetastoreUtil.getHiveSchema(finalTable.get());
schema.setProperty("tablePath", finalTable.get().getStorage().getLocation());
Properties schema = MetastoreUtil.getHiveSchema(table.get());
schema.setProperty("tablePath", table.get().getStorage().getLocation());
carbonTable = getCarbonTable(parent.getSchemaName(),
parent.getTableName(),
schema,
@ -470,13 +446,13 @@ public class CarbondataMetadata
HiveInsertTableHandle parent = super.beginInsert(session, tableHandle);
List<HiveColumnHandle> inputColumns = parent.getInputColumns().stream().filter(HiveColumnHandle::isRequired).collect(toList());
SchemaTableName tableName = parent.getSchemaTableName();
Optional<Table> finalTable =
Optional<Table> table =
this.metastore.getTable(new HiveIdentity(session), tableName.getSchemaName(), tableName.getTableName());
if (finalTable.isPresent() && finalTable.get().getPartitionColumns().size() > 0) {
if (table.isPresent() && table.get().getPartitionColumns().size() > 0) {
throw new PrestoException(NOT_SUPPORTED, "Operations on Partitioned CarbonTables is not supported");
}
this.table = finalTable;
this.table = table;
this.user = session.getUser();
hdfsEnvironment.doAs(user, () -> {
initialConfiguration = ConfigurationUtils.toJobConf(this.hdfsEnvironment
@ -484,8 +460,8 @@ public class CarbondataMetadata
new HdfsEnvironment.HdfsContext(session, parent.getSchemaName(),
parent.getTableName()),
new Path(parent.getLocationHandle().getJsonSerializableWritePath())));
Properties schema = MetastoreUtil.getHiveSchema(finalTable.get());
schema.setProperty("tablePath", finalTable.get().getStorage().getLocation());
Properties schema = MetastoreUtil.getHiveSchema(table.get());
schema.setProperty("tablePath", table.get().getStorage().getLocation());
carbonTable = getCarbonTable(parent.getSchemaName(),
parent.getTableName(),
schema,
@ -643,7 +619,7 @@ public class CarbondataMetadata
return hdfsEnvironment.doAs(session.getUser(), () -> {
Properties hiveSchema = MetastoreUtil.getHiveSchema(this.table.get());
CarbonTable finalCarbonTable = getCarbonTable(carbondataVacuumTableHandle.getSchemaName(),
CarbonTable carbonTable = getCarbonTable(carbondataVacuumTableHandle.getSchemaName(),
carbondataVacuumTableHandle.getTableName(),
hiveSchema,
initialConfiguration);
@ -705,7 +681,7 @@ public class CarbondataMetadata
SegmentFileStore.mergeSegmentFiles(readPath, segmentFileName, CarbonTablePath.getSegmentFilesLocation(carbonLoadModel.getTablePath()));
String source;
for (String currPartitionName : partitionNames) {
source = finalCarbonTable.getTablePath() + "/" + currPartitionName;
source = carbonTable.getTablePath() + "/" + currPartitionName;
moveFromTempFolder(source + "/" + carbonLoadModel.getSegmentId() + "_" + timeStamp + ".tmp", source);
}
segmentFilesToBeUpdatedLatest.add(new Segment(carbonLoadModel.getSegmentId(), segmentFileName));
@ -719,7 +695,7 @@ public class CarbondataMetadata
for (CarbondataSegmentInfoUtil segmentInfo : newMergedSegmentInfoUtilList) {
String mergedLoadNumber = segmentInfo.getDestinationSegment();
try {
String segmentFileName = SegmentFileStore.writeSegmentFile(finalCarbonTable, mergedLoadNumber, String.valueOf(carbonLoadModel.getFactTimeStamp()));
String segmentFileName = SegmentFileStore.writeSegmentFile(carbonTable, mergedLoadNumber, String.valueOf(carbonLoadModel.getFactTimeStamp()));
}
catch (IOException e) {
throw new PrestoException(GENERIC_INTERNAL_ERROR, "Failed while merging segment files", e);
@ -875,14 +851,6 @@ public class CarbondataMetadata
case DROP_TABLE: {
break;
}
case ADD_COLUMN:
case DROP_COLUMN:
case RENAME_COLUMN: {
hdfsEnvironment.doAs(user, () -> {
revertAlterTableChanges();
});
break;
}
default: {
return;
}
@ -900,9 +868,9 @@ public class CarbondataMetadata
private LocationHandle getCarbonDataTableCreationPath(ConnectorSession session, ConnectorTableMetadata tableMetadata, HiveWriteUtils.OpertionType opertionType) throws PrestoException
{
Path targetPath = null;
SchemaTableName finalSchemaTableName = tableMetadata.getTable();
String finalSchemaName = finalSchemaTableName.getSchemaName();
String tableName = finalSchemaTableName.getTableName();
SchemaTableName schemaTableName = tableMetadata.getTable();
String schemaName = schemaTableName.getSchemaName();
String tableName = schemaTableName.getTableName();
Optional<String> location = getCarbondataLocation(tableMetadata.getProperties());
LocationHandle locationHandle;
FileSystem fileSystem;
@ -914,32 +882,32 @@ public class CarbondataMetadata
throw new PrestoException(NOT_SUPPORTED, format("Setting %s property is not allowed", LOCATION_PROPERTY));
}
/* if path not having prefix with filesystem type, than we will take fileSystem type from core-site.xml using below methods */
fileSystem = hdfsEnvironment.getFileSystem(new HdfsEnvironment.HdfsContext(session, finalSchemaName), new Path(location.get()));
fileSystem = hdfsEnvironment.getFileSystem(new HdfsEnvironment.HdfsContext(session, schemaName), new Path(location.get()));
targetLocation = fileSystem.getFileStatus(new Path(location.get())).getPath().toString();
targetPath = getPath(new HdfsEnvironment.HdfsContext(session, finalSchemaName, tableName), targetLocation, false);
targetPath = getPath(new HdfsEnvironment.HdfsContext(session, schemaName, tableName), targetLocation, false);
}
else {
updateEmptyCarbondataTableStorePath(session, finalSchemaName);
updateEmptyCarbondataTableStorePath(session, schemaName);
targetLocation = carbondataTableStore;
targetLocation = targetLocation + File.separator + finalSchemaName + File.separator + tableName;
targetLocation = targetLocation + File.separator + schemaName + File.separator + tableName;
targetPath = new Path(targetLocation);
}
}
catch (IllegalArgumentException | IOException e) {
throw new PrestoException(NOT_SUPPORTED, format("Error %s store path %s ", e.getMessage(), targetLocation));
}
locationHandle = locationService.forNewTable(metastore, session, finalSchemaName, tableName, Optional.empty(), Optional.of(targetPath), opertionType);
locationHandle = locationService.forNewTable(metastore, session, schemaName, tableName, Optional.empty(), Optional.of(targetPath), opertionType);
return locationHandle;
}
@Override
public void createTable(ConnectorSession session, ConnectorTableMetadata tableMetadata, boolean ignoreExisting)
{
SchemaTableName localSchemaTableName = tableMetadata.getTable();
String localSchemaName = localSchemaTableName.getSchemaName();
String tableName = localSchemaTableName.getTableName();
SchemaTableName schemaTableName = tableMetadata.getTable();
String schemaName = schemaTableName.getSchemaName();
String tableName = schemaTableName.getTableName();
this.user = session.getUser();
this.schemaName = localSchemaName;
this.schemaName = schemaName;
currentState = State.CREATE_TABLE;
List<String> partitionedBy = new ArrayList<String>();
List<SortingColumn> sortBy = new ArrayList<SortingColumn>();
@ -947,29 +915,29 @@ public class CarbondataMetadata
Map<String, String> tableProperties = new HashMap<String, String>();
getParametersForCreateTable(session, tableMetadata, partitionedBy, sortBy, columnHandles, tableProperties);
metastore.getDatabase(localSchemaName).orElseThrow(() -> new SchemaNotFoundException(localSchemaName));
metastore.getDatabase(schemaName).orElseThrow(() -> new SchemaNotFoundException(schemaName));
BaseStorageFormat hiveStorageFormat = CarbondataTableProperties.getCarbondataStorageFormat(tableMetadata.getProperties());
// it will get final path to create carbon table
LocationHandle locationHandle = getCarbonDataTableCreationPath(session, tableMetadata, HiveWriteUtils.OpertionType.CREATE_TABLE);
Path targetPath = locationService.getQueryWriteInfo(locationHandle).getTargetPath();
AbsoluteTableIdentifier finalAbsoluteTableIdentifier = AbsoluteTableIdentifier.from(targetPath.toString(),
new CarbonTableIdentifier(localSchemaName, tableName, UUID.randomUUID().toString()));
AbsoluteTableIdentifier absoluteTableIdentifier = AbsoluteTableIdentifier.from(targetPath.toString(),
new CarbonTableIdentifier(schemaName, tableName, UUID.randomUUID().toString()));
hdfsEnvironment.doAs(session.getUser(), () -> {
initialConfiguration = ConfigurationUtils.toJobConf(this.hdfsEnvironment.getConfiguration(
new HdfsEnvironment.HdfsContext(session, localSchemaName, tableName),
new HdfsEnvironment.HdfsContext(session, schemaName, tableName),
new Path(locationHandle.getJsonSerializableTargetPath())));
CarbondataMetadataUtils.createMetaDataFolderSchemaFile(hdfsEnvironment, session, columnHandles, finalAbsoluteTableIdentifier, partitionedBy,
CarbondataMetadataUtils.createMetaDataFolderSchemaFile(hdfsEnvironment, session, columnHandles, absoluteTableIdentifier, partitionedBy,
sortBy.stream().map(s -> s.getColumnName().toLowerCase(Locale.ENGLISH)).collect(toList()), targetPath.toString(), initialConfiguration);
this.tableStorageLocation = Optional.of(targetPath.toString());
try {
Map<String, String> serdeParameters = initSerDeProperties(tableName);
Table localTable = buildTableObject(
Table table = buildTableObject(
session.getQueryId(),
localSchemaName,
schemaName,
tableName,
session.getUser(),
columnHandles,
@ -981,11 +949,11 @@ public class CarbondataMetadata
true, // carbon table is set as external table
prestoVersion,
serdeParameters);
PrincipalPrivileges principalPrivileges = MetastoreUtil.buildInitialPrivilegeSet(localTable.getOwner());
HiveBasicStatistics basicStatistics = localTable.getPartitionColumns().isEmpty() ? HiveBasicStatistics.createZeroStatistics() : HiveBasicStatistics.createEmptyStatistics();
PrincipalPrivileges principalPrivileges = MetastoreUtil.buildInitialPrivilegeSet(table.getOwner());
HiveBasicStatistics basicStatistics = table.getPartitionColumns().isEmpty() ? HiveBasicStatistics.createZeroStatistics() : HiveBasicStatistics.createEmptyStatistics();
metastore.createTable(
session,
localTable,
table,
principalPrivileges,
Optional.empty(),
ignoreExisting,
@ -1051,15 +1019,6 @@ public class CarbondataMetadata
super.commit();
break;
}
case ADD_COLUMN:
case RENAME_COLUMN:
case DROP_COLUMN: {
hdfsEnvironment.doAs(user, () -> {
writeSchemaFile();
});
super.commit();
break;
}
default: {
super.commit();
}
@ -1092,8 +1051,8 @@ public class CarbondataMetadata
public CarbondataTableHandle getTableHandle(ConnectorSession session, SchemaTableName tableName)
{
requireNonNull(tableName, "tableName is null");
Optional<Table> finalTable = metastore.getTable(new HiveIdentity(session), tableName.getSchemaName(), tableName.getTableName());
if (!finalTable.isPresent()) {
Optional<Table> table = metastore.getTable(new HiveIdentity(session), tableName.getSchemaName(), tableName.getTableName());
if (!table.isPresent()) {
return null;
}
@ -1102,14 +1061,14 @@ public class CarbondataMetadata
throw new PrestoException(HiveErrorCode.HIVE_INVALID_METADATA, "Unexpected table present in Hive metastore: " + tableName);
}
MetastoreUtil.verifyOnline(tableName, Optional.empty(), MetastoreUtil.getProtectMode(finalTable.get()), finalTable.get().getParameters());
MetastoreUtil.verifyOnline(tableName, Optional.empty(), MetastoreUtil.getProtectMode(table.get()), table.get().getParameters());
return new CarbondataTableHandle(
tableName.getSchemaName(),
tableName.getTableName(),
finalTable.get().getParameters(),
getPartitionKeyColumnHandles(finalTable.get()),
HiveBucketing.getHiveBucketHandle(finalTable.get()));
table.get().getParameters(),
getPartitionKeyColumnHandles(table.get()),
HiveBucketing.getHiveBucketHandle(table.get()));
}
private Optional<ConnectorOutputMetadata> finishUpdateAndDelete(ConnectorSession session,
@ -1133,12 +1092,12 @@ public class CarbondataMetadata
hdfsEnvironment.doAs(user, () -> {
if (blockUpdateDetailsList.size() > 0) {
CarbonTable finalCarbonTable = getCarbonTable(tableHandle.getSchemaName(),
CarbonTable carbonTable = getCarbonTable(tableHandle.getSchemaName(),
tableHandle.getTableName(),
MetastoreUtil.getHiveSchema(table.get()),
initialConfiguration);
SegmentUpdateStatusManager statusManager = new SegmentUpdateStatusManager(finalCarbonTable);
SegmentUpdateStatusManager statusManager = new SegmentUpdateStatusManager(carbonTable);
SegmentUpdateDetails[] segementDetailsList = statusManager.getUpdateStatusDetails();
for (SegmentUpdateDetails segementDetails : segementDetailsList) {
segementDetails.getDeletedRowsInBlock();
@ -1179,26 +1138,26 @@ public class CarbondataMetadata
List<HiveColumnHandle> columnHandles,
Map<String, String> tableProperties)
{
SchemaTableName finalSchemaTableName = tableMetadata.getTable();
String finalSchemaName = finalSchemaTableName.getSchemaName();
String finalTableName = finalSchemaTableName.getTableName();
SchemaTableName schemaTableName = tableMetadata.getTable();
String schemaName = schemaTableName.getSchemaName();
String tableName = schemaTableName.getTableName();
partitionedBy.addAll(CarbondataTableProperties.getPartitionedBy(tableMetadata.getProperties()));
sortBy.addAll(CarbondataTableProperties.getSortedBy(tableMetadata.getProperties()));
Optional<HiveBucketProperty> bucketProperty = Optional.empty();
columnHandles.addAll(getColumnHandles(tableMetadata, ImmutableSet.copyOf(partitionedBy), typeTranslator));
tableProperties.putAll(getEmptyTableProperties(tableMetadata, bucketProperty, new HdfsEnvironment.HdfsContext(session, finalSchemaName, finalTableName)));
tableProperties.putAll(getEmptyTableProperties(tableMetadata, bucketProperty, new HdfsEnvironment.HdfsContext(session, schemaName, tableName)));
}
@Override
public CarbondataOutputTableHandle beginCreateTable(ConnectorSession session, ConnectorTableMetadata tableMetadata, Optional<ConnectorNewTableLayout> layout)
{
// get the root directory for the database
SchemaTableName finalSchemaTableName = tableMetadata.getTable();
String finalSchemaName = finalSchemaTableName.getSchemaName();
String finalTableName = finalSchemaTableName.getTableName();
SchemaTableName schemaTableName = tableMetadata.getTable();
String schemaName = schemaTableName.getSchemaName();
String tableName = schemaTableName.getTableName();
this.user = session.getUser();
this.schemaName = finalSchemaName;
this.schemaName = schemaName;
currentState = State.CREATE_TABLE_AS;
List<String> partitionedBy = new ArrayList<String>();
@ -1206,7 +1165,7 @@ public class CarbondataMetadata
List<HiveColumnHandle> columnHandles = new ArrayList<HiveColumnHandle>();
Map<String, String> tableProperties = new HashMap<String, String>();
getParametersForCreateTable(session, tableMetadata, partitionedBy, sortBy, columnHandles, tableProperties);
metastore.getDatabase(finalSchemaName).orElseThrow(() -> new SchemaNotFoundException(finalSchemaName));
metastore.getDatabase(schemaName).orElseThrow(() -> new SchemaNotFoundException(schemaName));
// to avoid type mismatch between HiveStorageFormat & Carbondata StorageFormat this hack no option
HiveStorageFormat tableStorageFormat = HiveStorageFormat.valueOf("CARBON");
@ -1222,29 +1181,29 @@ public class CarbondataMetadata
// it will get final path to create carbon table
LocationHandle locationHandle = getCarbonDataTableCreationPath(session, tableMetadata, HiveWriteUtils.OpertionType.CREATE_TABLE_AS);
Path targetPath = locationService.getTableWriteInfo(locationHandle, false).getTargetPath();
AbsoluteTableIdentifier finalAbsoluteTableIdentifier = AbsoluteTableIdentifier.from(targetPath.toString(),
new CarbonTableIdentifier(finalSchemaName, finalTableName, UUID.randomUUID().toString()));
AbsoluteTableIdentifier absoluteTableIdentifier = AbsoluteTableIdentifier.from(targetPath.toString(),
new CarbonTableIdentifier(schemaName, tableName, UUID.randomUUID().toString()));
hdfsEnvironment.doAs(session.getUser(), () -> {
initialConfiguration = ConfigurationUtils.toJobConf(this.hdfsEnvironment.getConfiguration(
new HdfsEnvironment.HdfsContext(session, finalSchemaName, finalTableName),
new HdfsEnvironment.HdfsContext(session, schemaName, tableName),
new Path(locationHandle.getJsonSerializableTargetPath())));
// Create Carbondata metadata folder and Schema file
CarbondataMetadataUtils.createMetaDataFolderSchemaFile(hdfsEnvironment, session, columnHandles, finalAbsoluteTableIdentifier, partitionedBy,
CarbondataMetadataUtils.createMetaDataFolderSchemaFile(hdfsEnvironment, session, columnHandles, absoluteTableIdentifier, partitionedBy,
sortBy.stream().map(s -> s.getColumnName().toLowerCase(Locale.ENGLISH)).collect(toList()), targetPath.toString(), initialConfiguration);
this.tableStorageLocation = Optional.of(targetPath.toString());
Path outputPath = new Path(locationHandle.getJsonSerializableTargetPath());
Properties schema = readSchemaForCarbon(finalSchemaName, finalTableName, targetPath, columnHandles, partitionColumns);
Properties schema = readSchemaForCarbon(schemaName, tableName, targetPath, columnHandles, partitionColumns);
// Create committer object
setupCommitWriter(schema, outputPath, initialConfiguration, false);
});
try {
CarbondataOutputTableHandle result = new CarbondataOutputTableHandle(
finalSchemaName,
finalTableName,
schemaName,
tableName,
columnHandles,
metastore.generatePageSinkMetadata(new HiveIdentity(session), finalSchemaTableName),
metastore.generatePageSinkMetadata(new HiveIdentity(session), schemaTableName),
locationHandle,
tableStorageFormat,
partitionStorageFormat,
@ -1255,7 +1214,7 @@ public class CarbondataMetadata
EncodedLoadModel, jobContext.getConfiguration().get(LOAD_MODEL)));
LocationService.WriteInfo writeInfo = locationService.getQueryWriteInfo(locationHandle);
metastore.declareIntentionToWrite(session, writeInfo.getWriteMode(), writeInfo.getWritePath(), finalSchemaTableName);
metastore.declareIntentionToWrite(session, writeInfo.getWriteMode(), writeInfo.getWritePath(), schemaTableName);
return result;
}
catch (RuntimeException ex) {
@ -1386,7 +1345,7 @@ public class CarbondataMetadata
List<Segment> segmentFilesToBeUpdated = blockUpdateDetailsList.stream()
.map(SegmentUpdateDetails::getSegmentName)
.map(Segment::new).collect(Collectors.toList());
List<Segment> finalSegmentFilesToBeUpdatedLatest = new ArrayList<>();
List<Segment> segmentFilesToBeUpdatedLatest = new ArrayList<>();
List<Segment> segmentFilesToBeDeleted = blockUpdateDetailsList.stream()
.filter(segmentUpdateDetails -> segmentUpdateDetails.getSegmentStatus() != null &&
segmentUpdateDetails.getSegmentStatus().equals(SegmentStatus.MARKED_FOR_DELETE))
@ -1396,12 +1355,12 @@ public class CarbondataMetadata
for (Segment segment : segmentFilesToBeUpdated) {
String file =
SegmentFileStore.writeSegmentFile(carbonTable, segment.getSegmentNo(), timeStamp.toString());
finalSegmentFilesToBeUpdatedLatest.add(new Segment(segment.getSegmentNo(), file));
segmentFilesToBeUpdatedLatest.add(new Segment(segment.getSegmentNo(), file));
}
if (!(updateSegmentStatusSuccess &&
CarbonUpdateUtil.updateTableMetadataStatus(new HashSet<>(segmentFilesToBeUpdated),
carbonTable, timeStamp.toString(), true, segmentFilesToBeDeleted,
finalSegmentFilesToBeUpdatedLatest, ""))) {
segmentFilesToBeUpdatedLatest, ""))) {
CarbonUpdateUtil.cleanStaleDeltaFiles(carbonTable, timeStamp.toString());
}
}
@ -1463,10 +1422,11 @@ public class CarbondataMetadata
Properties hiveschema = MetastoreUtil.getHiveSchema(table);
Configuration configuration = jobContext.getConfiguration();
configuration.set(SET_OVERWRITE, "false");
CarbonLoadModel loadModel = HiveCarbonUtil.getCarbonLoadModel(hiveschema, configuration);
LoadMetadataDetails loadMetadataDetails = loadModel.getCurrentLoadMetadataDetail();
loadModel.setSegmentId(loadMetadataDetails.getLoadName());
CarbonLoaderUtil.recordNewLoadMetadata(loadMetadataDetails, loadModel, false, true);
CarbonLoadModel carbonLoadModel =
HiveCarbonUtil.getCarbonLoadModel(hiveschema, configuration);
LoadMetadataDetails loadMetadataDetails = carbonLoadModel.getCurrentLoadMetadataDetail();
carbonLoadModel.setSegmentId(loadMetadataDetails.getLoadName());
CarbonLoaderUtil.recordNewLoadMetadata(loadMetadataDetails, carbonLoadModel, false, true);
}
catch (IOException e) {
LOG.error("Error occurred while committing the insert job.", e);
@ -1553,14 +1513,14 @@ public class CarbondataMetadata
try {
hdfsEnvironment.doAs(session.getUser(), () -> {
metastore.dropTable(session, handle.getSchemaName(), handle.getTableName());
Configuration finalInitialConfiguration = ConfigurationUtils.toJobConf(this.hdfsEnvironment
Configuration initialConfiguration = ConfigurationUtils.toJobConf(this.hdfsEnvironment
.getConfiguration(new HdfsEnvironment.HdfsContext(session, handle.getSchemaName(),
handle.getTableName()), new Path(this.tableStorageLocation.get())));
Properties schema = MetastoreUtil.getHiveSchema(target.get());
schema.setProperty("tablePath", this.tableStorageLocation.get());
this.carbonTable = getCarbonTable(handle.getSchemaName(), handle.getTableName(),
schema, finalInitialConfiguration);
schema, initialConfiguration);
takeLocks(State.DROP_TABLE);
AbsoluteTableIdentifier identifier = this.carbonTable.getAbsoluteTableIdentifier();
if (SegmentStatusManager.isLoadInProgressInTable(carbonTable)) {
@ -1569,7 +1529,7 @@ public class CarbondataMetadata
try {
//Simultaneous case after acquiring locks we should check table exist.
//if table is not there clean the lock folders
carbonTable = getCarbonTable(handle.getSchemaName(), handle.getTableName(), schema, finalInitialConfiguration);
carbonTable = getCarbonTable(handle.getSchemaName(), handle.getTableName(), schema, initialConfiguration);
}//CarbonFileException
catch (RuntimeException e) {
try {
@ -1620,350 +1580,6 @@ public class CarbondataMetadata
return serdeParameters;
}
@Override
public void addColumn(ConnectorSession session, ConnectorTableHandle tableHandle, ColumnMetadata column)
{
currentState = State.ADD_COLUMN;
updateSchemaInfo(session, tableHandle, column, null, null);
super.addColumn(session, tableHandle, column);
}
@Override
public void renameColumn(ConnectorSession session, ConnectorTableHandle tableHandle, ColumnHandle source, String target)
{
currentState = State.RENAME_COLUMN;
updateSchemaInfo(session, tableHandle, null, source, target);
super.renameColumn(session, tableHandle, source, target);
}
@Override
public void dropColumn(ConnectorSession session, ConnectorTableHandle tableHandle, ColumnHandle column)
{
currentState = State.DROP_COLUMN;
updateSchemaInfo(session, tableHandle, null, column, null);
super.dropColumn(session, tableHandle, column);
}
private void updateSchemaInfo(ConnectorSession session, ConnectorTableHandle tableHandle, ColumnMetadata column, ColumnHandle source, String target)
{
HiveTableHandle handle = (HiveTableHandle) tableHandle;
table = metastore.getTable(new HiveIdentity(session), handle.getSchemaName(), handle.getTableName());
String tablePath = table.get().getStorage().getLocation();
hdfsEnvironment.doAs(user, () -> {
initialConfiguration = ConfigurationUtils.toJobConf(this.hdfsEnvironment
.getConfiguration(
new HdfsEnvironment.HdfsContext(session, handle.getSchemaName(),
handle.getTableName()), new Path(tablePath)));
Properties schema = MetastoreUtil.getHiveSchema(table.get());
schema.setProperty("tablePath", tablePath);
carbonTable = getCarbonTable(handle.getSchemaName(),
handle.getTableName(),
schema,
initialConfiguration);
});
acquireLocksForAlter();
schemaTableName = handle.getSchemaTableName();
absoluteTableIdentifier = AbsoluteTableIdentifier.from(tablePath, handle.getTableName(), handle.getSchemaName());
tableInfo = carbonTable.getTableInfo();
SchemaEvolutionEntry schemaEvolutionEntry;
switch (currentState) {
case ADD_COLUMN: {
schemaEvolutionEntry = updateSchemaInfoAddColumn(column);
break;
}
case RENAME_COLUMN: {
schemaEvolutionEntry = updateSchemaInfoRenameColumn(source, target);
break;
}
case DROP_TABLE: {
schemaEvolutionEntry = updateSchemaInfoDropColumn(source);
break;
}
default: {
return;
}
}
if (schemaEvolutionEntry != null) {
tableInfo.getFactTable().getSchemaEvolution().getSchemaEvolutionEntryList()
.add(schemaEvolutionEntry);
}
}
private SchemaEvolutionEntry updateSchemaInfoAddColumn(ColumnMetadata column)
{
HiveColumnHandle columnHandle = new HiveColumnHandle(column.getName(), HiveType.toHiveType(typeTranslator, column.getType()),
column.getType().getTypeSignature(), tableInfo.getFactTable().getListOfColumns().size(), HiveColumnHandle.ColumnType.REGULAR, Optional.empty());
TableSchema tableSchema = tableInfo.getFactTable();
List<ColumnSchema> tableColumns = tableSchema.getListOfColumns();
int currentSchemaOrdinal = tableColumns.stream().max(Comparator.comparing(ColumnSchema::getSchemaOrdinal))
.orElseThrow(NoSuchElementException::new).getSchemaOrdinal() + 1;
List<ColumnSchema> longStringColumns = new ArrayList<>();
List<ColumnSchema> allColumns = tableColumns.stream().filter(cols -> cols.isDimensionColumn()
&& !cols.getDataType().isComplexType() && cols.getSchemaOrdinal() != -1 && (cols.getDataType() != DataTypes.VARCHAR)).collect(toList());
TableSchemaBuilder schemaBuilder = new TableSchemaBuilder();
List<ColumnSchema> columnSchemas = new ArrayList<ColumnSchema>();
ColumnSchema newColumn = schemaBuilder.addColumn(new StructField(columnHandle.getName(),
CarbondataHetuFilterUtil.spi2CarbondataTypeMapper(columnHandle)), null,
false, false);
newColumn.setSchemaOrdinal(currentSchemaOrdinal);
columnSchemas.add(newColumn);
if (newColumn.getDataType() == DataTypes.VARCHAR) {
longStringColumns.add(newColumn);
}
else if (newColumn.isDimensionColumn()) {
// add the column which is not long string
allColumns.add(newColumn);
}
// put the old long string columns
allColumns.addAll(tableColumns.stream().filter(cols -> cols.isDimensionColumn() && (cols.getDataType() == DataTypes.VARCHAR)).collect(toList()));
// and the new long string column after old long string columns
allColumns.addAll(longStringColumns);
// put complex type columns at the end of dimension columns
allColumns.addAll(tableColumns.stream().filter(cols -> cols.isDimensionColumn() &&
(cols.isComplexColumn() || cols.getSchemaOrdinal() == -1)).collect(toList()));
// original measure columns
allColumns.addAll(tableColumns.stream().filter(cols -> !cols.isDimensionColumn()).collect(toList()));
// add new measure column
if (!newColumn.isDimensionColumn()) {
allColumns.add(newColumn);
}
allColumns.stream().filter(cols -> !cols.isInvisible()).collect(Collectors.groupingBy(ColumnSchema::getColumnName))
.forEach((columnName, schemaList) -> {
if (schemaList.size() > 2) {
throw new PrestoException(GENERIC_INTERNAL_ERROR, format("Duplicate columns found"));
}
});
if (newColumn.isComplexColumn()) {
throw new PrestoException(GENERIC_INTERNAL_ERROR, format("Complex column cannot be added"));
}
List<ColumnSchema> finalAllColumns = allColumns;
allColumns.stream().forEach(columnSchema -> {
List<ColumnSchema> colWithSameId = finalAllColumns.stream().filter(x ->
x.getColumnUniqueId().equals(columnSchema.getColumnUniqueId())).collect(toList());
if (colWithSameId.size() > 1) {
throw new PrestoException(GENERIC_INTERNAL_ERROR, format("Two columns can not have same columnId"));
}
});
if (tableInfo.getFactTable().getPartitionInfo() != null) {
List<ColumnSchema> par = tableInfo.getFactTable().getPartitionInfo().getColumnSchemaList();
allColumns = allColumns.stream().filter(cols -> !par.contains(cols)).collect(toList());
allColumns.addAll(par);
}
tableSchema.setListOfColumns(allColumns);
tableInfo.setLastUpdatedTime(timeStamp);
tableInfo.setFactTable(tableSchema);
SchemaEvolutionEntry schemaEvolutionEntry = new SchemaEvolutionEntry();
schemaEvolutionEntry.setTimeStamp(timeStamp);
schemaEvolutionEntry.setAdded(columnSchemas);
return schemaEvolutionEntry;
}
private SchemaEvolutionEntry updateSchemaInfoRenameColumn(ColumnHandle source, String target)
{
HiveColumnHandle oldColumnHandle = (HiveColumnHandle) source;
String oldColumnName = oldColumnHandle.getColumnName();
String newColumnName = target;
if (!carbonTable.canAllow(carbonTable, TableOperation.ALTER_COLUMN_RENAME, oldColumnHandle.getName())) {
throw new PrestoException(GENERIC_INTERNAL_ERROR, format("Alter table rename column is not supported for index indexschema"));
}
TableSchema tableSchema = tableInfo.getFactTable();
List<ColumnSchema> tableColumns = tableSchema.getListOfColumns();
if (!tableColumns.stream().map(cols -> cols.getColumnName()).collect(toList()).contains(oldColumnHandle.getName())) {
throw new PrestoException(GENERIC_INTERNAL_ERROR, format("Column " + oldColumnHandle.getName() + "does not exist in " +
carbonTable.getDatabaseName() + "." + carbonTable.getTableName()));
}
List<ColumnSchema> carbonColumns = carbonTable.getCreateOrderColumn().stream().filter(cols -> !cols.isInvisible())
.map(cols -> cols.getColumnSchema()).collect(toList());
ColumnSchema oldCarbonColumn = carbonColumns.stream().filter(cols -> cols.getColumnName().equalsIgnoreCase(oldColumnName)).findFirst().get();
validateColumnsForRenaming(oldCarbonColumn);
TableSchemaBuilder schemaBuilder = new TableSchemaBuilder();
ColumnSchema deletedColumn = schemaBuilder.addColumn(new StructField(oldColumnHandle.getName(),
CarbondataHetuFilterUtil.spi2CarbondataTypeMapper(oldColumnHandle)), null, false, false);
SchemaEvolutionEntry schemaEvolutionEntry = new SchemaEvolutionEntry();
tableColumns.forEach(cols -> {
if (cols.getColumnName().equalsIgnoreCase(oldColumnName)) {
cols.setColumnName(newColumnName);
schemaEvolutionEntry.setTimeStamp(timeStamp);
schemaEvolutionEntry.setAdded(Arrays.asList(cols));
schemaEvolutionEntry.setRemoved(Arrays.asList(deletedColumn));
}
});
Map<String, String> tableProperties = tableInfo.getFactTable().getTableProperties();
tableProperties.forEach((tablePropertyKey, tablePropertyValue) -> {
if (tablePropertyKey.equalsIgnoreCase(oldColumnName)) {
tableProperties.put(tablePropertyKey, newColumnName);
}
});
tableInfo.setLastUpdatedTime(System.currentTimeMillis());
tableInfo.setFactTable(tableSchema);
return schemaEvolutionEntry;
}
private SchemaEvolutionEntry updateSchemaInfoDropColumn(ColumnHandle column)
{
HiveColumnHandle columnHandle = (HiveColumnHandle) column;
TableSchema tableSchema = tableInfo.getFactTable();
List<ColumnSchema> tableColumns = tableSchema.getListOfColumns();
int currentSchemaOrdinal = tableColumns.stream().max(Comparator.comparing(ColumnSchema::getSchemaOrdinal))
.orElseThrow(NoSuchElementException::new).getSchemaOrdinal() + 1;
TableSchemaBuilder schemaBuilder = new TableSchemaBuilder();
List<ColumnSchema> columnSchemas = new ArrayList<ColumnSchema>();
ColumnSchema newColumn = schemaBuilder.addColumn(new StructField(columnHandle.getColumnName(),
CarbondataHetuFilterUtil.spi2CarbondataTypeMapper(columnHandle)), null,
false, false);
newColumn.setSchemaOrdinal(currentSchemaOrdinal);
columnSchemas.add(newColumn);
PartitionInfo partitionInfo = tableInfo.getFactTable().getPartitionInfo();
if (partitionInfo != null) {
List<String> partitionColumnSchemaList = tableInfo.getFactTable().getPartitionInfo()
.getColumnSchemaList().stream().map(cols -> cols.getColumnName()).collect(toList());
if (partitionColumnSchemaList.stream().anyMatch(partitionColumn -> partitionColumn.equals(newColumn.getColumnName()))) {
throw new PrestoException(GENERIC_INTERNAL_ERROR, "Partition columns cannot be dropped");
}
// when table has two columns, dropping unpartitioned column will be wrong
if (tableColumns.stream().filter(cols -> !cols.getColumnName().equals(newColumn.getColumnName()))
.map(cols -> cols.getColumnName()).equals(partitionColumnSchemaList)) {
throw new PrestoException(GENERIC_INTERNAL_ERROR, "Cannot have table with all columns as partition columns");
}
}
if (!tableColumns.stream().filter(cols -> cols.getColumnName().equals(newColumn.getColumnName())).collect(toList()).isEmpty()) {
if (newColumn.isComplexColumn()) {
throw new PrestoException(GENERIC_INTERNAL_ERROR, "Complex column cannot be dropped");
}
}
else {
throw new PrestoException(GENERIC_INTERNAL_ERROR, "Cannot have table with all columns as partition columns");
}
tableInfo.setLastUpdatedTime(System.currentTimeMillis());
tableInfo.setFactTable(tableSchema);
SchemaEvolutionEntry schemaEvolutionEntry = new SchemaEvolutionEntry();
schemaEvolutionEntry.setTimeStamp(timeStamp);
schemaEvolutionEntry.setRemoved(columnSchemas);
return schemaEvolutionEntry;
}
private void revertAlterTableChanges()
{
String tableName = absoluteTableIdentifier.getTableName();
String databaseName = absoluteTableIdentifier.getDatabaseName();
TableInfo finalTableInfo = carbonTable.getTableInfo();
List<SchemaEvolutionEntry> evolutionEntryList = finalTableInfo.getFactTable().getSchemaEvolution().getSchemaEvolutionEntryList();
Long updatedTime = evolutionEntryList.get(evolutionEntryList.size() - 1).getTimeStamp();
LOG.info("Reverting changes for " + databaseName + "." + tableName);
List<ColumnSchema> addedSchemas = evolutionEntryList.get(evolutionEntryList.size() - 1).getAdded();
List<ColumnSchema> removedSchemas = evolutionEntryList.get(evolutionEntryList.size() - 1).getRemoved();
if (updatedTime == timeStamp) {
switch (currentState) {
case ADD_COLUMN: {
carbonTable.getTableInfo().getFactTable().getListOfColumns().removeAll(addedSchemas);
break;
}
case DROP_COLUMN: {
finalTableInfo.getFactTable().getListOfColumns().forEach(cols -> removedSchemas.forEach(removedCols -> {
if (cols.isInvisible() && removedCols.getColumnUniqueId().equals(cols.getColumnUniqueId())) {
cols.setInvisible(false);
}
}));
break;
}
default:
break;
}
evolutionEntryList.remove(evolutionEntryList.size() - 1);
writeSchemaFile();
}
}
private void writeSchemaFile()
{
try {
String schemaFilePath = CarbonTablePath.getSchemaFilePath(table.get().getStorage().getLocation());
SchemaConverter schemaConverter = new ThriftWrapperSchemaConverterImpl();
ThriftWriter thriftWriter = new ThriftWriter(schemaFilePath, false);
thriftWriter.open(FileWriteOperation.OVERWRITE);
thriftWriter.write(schemaConverter.fromWrapperToExternalTableInfo(tableInfo, absoluteTableIdentifier.getTableName(),
absoluteTableIdentifier.getDatabaseName()));
thriftWriter.close();
FileFactory.getCarbonFile(schemaFilePath).setLastModifiedTime(timeStamp);
carbondataTableReader.deleteTableFromCarbonCache(new SchemaTableName(absoluteTableIdentifier.getDatabaseName(), absoluteTableIdentifier.getTableName()));
CarbonMetadata.getInstance().removeTable(absoluteTableIdentifier.getTablePath(), absoluteTableIdentifier.getDatabaseName());
CarbonMetadata.getInstance().loadTableMetadata(tableInfo);
LOG.info("Schema file written");
}
catch (IOException e) {
//TODO handle cases while exception thrown
releaseLocks();
throw new PrestoException(GENERIC_INTERNAL_ERROR, format("Error while writing to schema file", e));
}
}
private void acquireLocksForAlter()
{
metadataLock = CarbonLockFactory.getCarbonLockObj(carbonTable
.getAbsoluteTableIdentifier(), LockUsage.METADATA_LOCK);
compactionLock = CarbonLockFactory.getCarbonLockObj(carbonTable
.getAbsoluteTableIdentifier(), LockUsage.COMPACTION_LOCK);
try {
boolean lockStatus = metadataLock.lockWithRetries();
if (lockStatus) {
LOG.info("Successfully able to get the table metadata file lock");
}
else {
throw new Exception("Table is already locked");
}
if (compactionLock.lockWithRetries()) {
LOG.info("Successfully able to get compaction lock");
}
else {
throw new RuntimeException("Unable to get compaction locks");
}
}
catch (Exception e) {
LOG.error("Exception in alter operation", e);
releaseLocks();
throw new PrestoException(GENERIC_INTERNAL_ERROR, "Error while taking locks", e);
}
}
private void validateColumnsForRenaming(ColumnSchema oldColumn)
{
if (carbonTable != null) {
// if the column rename is for complex column, block the operation
if (oldColumn.isComplexColumn()) {
throw new PrestoException(GENERIC_INTERNAL_ERROR, format("Rename column is not supported for complex datatype"));
}
// if column rename operation is on partition column, then fail the rename operation
if (null != carbonTable.getPartitionInfo()) {
List<ColumnSchema> partitionColumns = carbonTable.getPartitionInfo().getColumnSchemaList();
if (!partitionColumns.stream().filter(cols -> cols.getColumnName()
.equalsIgnoreCase(oldColumn.getColumnName())).collect(toList()).isEmpty()) {
throw new PrestoException(GENERIC_INTERNAL_ERROR, format("Cannot rename a partition column"));
}
}
}
}
private void writeSegmentFileAndSetLoadModel()
{
hdfsEnvironment.doAs(user, () -> {
@ -2026,38 +1642,38 @@ public class CarbondataMetadata
@Override
protected ConnectorTableMetadata doGetTableMetadata(ConnectorSession session, SchemaTableName tableName)
{
Optional<Table> finalTable = metastore.getTable(new HiveIdentity(session), tableName.getSchemaName(), tableName.getTableName());
if (!finalTable.isPresent() || finalTable.get().getTableType().equals(TableType.VIRTUAL_VIEW.name())) {
Optional<Table> table = metastore.getTable(new HiveIdentity(session), tableName.getSchemaName(), tableName.getTableName());
if (!table.isPresent() || table.get().getTableType().equals(TableType.VIRTUAL_VIEW.name())) {
throw new TableNotFoundException(tableName);
}
Function<HiveColumnHandle, ColumnMetadata> metadataGetter = columnMetadataGetter(finalTable.get(), typeManager);
Function<HiveColumnHandle, ColumnMetadata> metadataGetter = columnMetadataGetter(table.get(), typeManager);
ImmutableList.Builder<ColumnMetadata> columns = ImmutableList.builder();
for (HiveColumnHandle columnHandle : hiveColumnHandles(finalTable.get())) {
for (HiveColumnHandle columnHandle : hiveColumnHandles(table.get())) {
columns.add(metadataGetter.apply(columnHandle));
}
// External location property
ImmutableMap.Builder<String, Object> properties = ImmutableMap.builder();
properties.put(LOCATION_PROPERTY, finalTable.get().getStorage().getLocation());
properties.put(LOCATION_PROPERTY, table.get().getStorage().getLocation());
// Storage format property
properties.put(HiveTableProperties.STORAGE_FORMAT_PROPERTY, CarbondataStorageFormat.CARBON);
// Partitioning property
List<String> partitionedBy = finalTable.get().getPartitionColumns().stream()
List<String> partitionedBy = table.get().getPartitionColumns().stream()
.map(Column::getName)
.collect(toList());
if (!partitionedBy.isEmpty()) {
properties.put(HiveTableProperties.PARTITIONED_BY_PROPERTY, partitionedBy);
}
Optional<String> comment = Optional.ofNullable(finalTable.get().getParameters().get(TABLE_COMMENT));
Optional<String> comment = Optional.ofNullable(table.get().getParameters().get(TABLE_COMMENT));
// add partitioned columns into immutableColumns
ImmutableList.Builder<ColumnMetadata> immutableColumns = ImmutableList.builder();
for (HiveColumnHandle columnHandle : hiveColumnHandles(finalTable.get())) {
for (HiveColumnHandle columnHandle : hiveColumnHandles(table.get())) {
if (columnHandle.getColumnType().equals(HiveColumnHandle.ColumnType.PARTITION_KEY)) {
immutableColumns.add(metadataGetter.apply(columnHandle));
}

View File

@ -191,7 +191,7 @@ public class CarbondataMetadataFactory
@Override
public HiveMetadata get()
{
SemiTransactionalHiveMetastore semiTransactionalHiveMetastore =
SemiTransactionalHiveMetastore metastore =
new SemiTransactionalHiveMetastore(this.hdfsEnvironment,
CachingHiveMetastore.memoizeMetastore(this.metastore, this.perTransactionCacheMaximumSize),
this.renameExecution,
@ -200,7 +200,7 @@ public class CarbondataMetadataFactory
this.hiveTransactionHeartbeatInterval,
this.heartbeatService, hiveMetastoreClientService, hmsWriteBatchSize);
return new CarbondataMetadata(semiTransactionalHiveMetastore,
return new CarbondataMetadata(metastore,
this.hdfsEnvironment,
this.partitionManager,
this.writesToNonManagedTablesEnabled,
@ -212,8 +212,8 @@ public class CarbondataMetadataFactory
this.segmentInfoCodec,
this.typeTranslator,
this.hetuVersion,
new MetastoreHiveStatisticsProvider(semiTransactionalHiveMetastore, statsCache, samplePartitionCache),
this.accessControlMetadataFactory.create(semiTransactionalHiveMetastore),
new MetastoreHiveStatisticsProvider(metastore, statsCache, samplePartitionCache),
this.accessControlMetadataFactory.create(metastore),
carbondataTableReader,
this.carbondataTableStore,
this.carbondataMajorVacuumSegmentSize,

View File

@ -167,9 +167,9 @@ public class CarbondataPageSink
{
//set flag here if called and change finish accordingly.
isCompactionCalled = true;
HdfsEnvironment finalHdfsEnvironment = connectorPageSource.getHdfsEnvironment();
HdfsEnvironment hdfsEnvironment = connectorPageSource.getHdfsEnvironment();
finalHdfsEnvironment.doAs(session.getUser(), () -> {
hdfsEnvironment.doAs(session.getUser(), () -> {
try {
// Worker part: each thread to run this code
boolean mergeStatus = false;

View File

@ -163,7 +163,6 @@ public class CarbondataPageSinkProvider
ImmutableMap.of(), handle.getAdditionalConf(), false);
}
@Override
public ConnectorPageSink createPageSink(ConnectorTransactionHandle transaction, ConnectorSession session, ConnectorOutputTableHandle tableHandle)
{
CarbondataOutputTableHandle handle = (CarbondataOutputTableHandle) tableHandle;

View File

@ -232,15 +232,15 @@ public class CarbondataPageSource
nanoStart = System.nanoTime();
}
CarbondataVectorBatch columnarBatch = null;
int columnBatchSize = 0;
int batchSize = 0;
try {
batchId++;
if (vectorReader.nextKeyValue()) {
Object vectorBatch = vectorReader.getCurrentValue();
if (vectorBatch instanceof CarbondataVectorBatch) {
columnarBatch = (CarbondataVectorBatch) vectorBatch;
columnBatchSize = columnarBatch.numRows();
if (columnBatchSize == 0) {
batchSize = columnarBatch.numRows();
if (batchSize == 0) {
close();
return null;
}
@ -256,9 +256,9 @@ public class CarbondataPageSource
Block[] blocks = new Block[columnHandles.size()];
for (int column = 0; column < blocks.length; column++) {
blocks[column] = new LazyBlock(columnBatchSize, new CarbondataBlockLoader(column));
blocks[column] = new LazyBlock(batchSize, new CarbondataBlockLoader(column));
}
Page page = new Page(columnBatchSize, blocks);
Page page = new Page(batchSize, blocks);
return page;
}
catch (PrestoException e) {

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2021. Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (C) 2018-2020. Huawei Technologies Co., Ltd. All rights reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at

View File

@ -90,17 +90,16 @@ public class CarbondataTableProperties
private static SortingColumn sortingColumnFromString(String name)
{
String finalName = name;
SortingColumn.Order order = SortingColumn.Order.ASCENDING;
String lower = name.toUpperCase(ENGLISH);
if (lower.endsWith(" ASC")) {
finalName = name.substring(0, name.length() - 4).trim();
name = name.substring(0, name.length() - 4).trim();
}
else if (lower.endsWith(" DESC")) {
finalName = name.substring(0, name.length() - 5).trim();
name = name.substring(0, name.length() - 5).trim();
order = SortingColumn.Order.DESCENDING;
}
return new SortingColumn(finalName, order);
return new SortingColumn(name, order);
}
private static String sortingColumnToString(SortingColumn column)

View File

@ -133,7 +133,6 @@ public class CarbondataWriterFactory
{
}
@Override
protected void setAdditionalSchemaProperties(Properties schema)
{
schema.setProperty(META_TABLE_LOCATION, locationService.getTableWriteInfo(locationHandle, false).getTargetPath().toString());

View File

@ -143,15 +143,14 @@ class ColumnarVectorWrapperDirect
@Override
public void putDecimals(int rowId, int count, BigDecimal value, int precision)
{
int inputRowId = rowId;
for (int i = 0; i < count; i++) {
if (nullBitSet.get(inputRowId)) {
columnVector.putNull(inputRowId);
if (nullBitSet.get(rowId)) {
columnVector.putNull(rowId);
}
else {
columnVector.putDecimal(inputRowId, value, precision);
columnVector.putDecimal(rowId, value, precision);
}
inputRowId++;
rowId++;
}
}
@ -186,9 +185,8 @@ class ColumnarVectorWrapperDirect
@Override
public void putByteArray(int rowId, int count, byte[] value)
{
int inputRowId = rowId;
for (int i = 0; i < count; i++) {
columnVector.putByteArray(inputRowId++, value);
columnVector.putByteArray(rowId++, value);
}
}
@ -305,90 +303,84 @@ class ColumnarVectorWrapperDirect
@Override
public void putFloats(int rowId, int count, float[] src, int srcIndex)
{
int inputRowId = rowId;
for (int i = 0; i < count; i++) {
if (nullBitSet.get(inputRowId)) {
columnVector.putNull(inputRowId);
if (nullBitSet.get(rowId)) {
columnVector.putNull(rowId);
}
else {
columnVector.putFloat(inputRowId, src[i]);
columnVector.putFloat(rowId, src[i]);
}
inputRowId++;
rowId++;
}
}
@Override
public void putShorts(int rowId, int count, short[] src, int srcIndex)
{
int inputRowId = rowId;
for (int i = 0; i < count; i++) {
if (nullBitSet.get(inputRowId)) {
columnVector.putNull(inputRowId);
if (nullBitSet.get(rowId)) {
columnVector.putNull(rowId);
}
else {
columnVector.putShort(inputRowId, src[i]);
columnVector.putShort(rowId, src[i]);
}
inputRowId++;
rowId++;
}
}
@Override
public void putInts(int rowId, int count, int[] src, int srcIndex)
{
int inputRowId = rowId;
for (int i = 0; i < count; i++) {
if (nullBitSet.get(inputRowId)) {
columnVector.putNull(inputRowId);
if (nullBitSet.get(rowId)) {
columnVector.putNull(rowId);
}
else {
columnVector.putInt(inputRowId, src[i]);
columnVector.putInt(rowId, src[i]);
}
inputRowId++;
rowId++;
}
}
@Override
public void putLongs(int rowId, int count, long[] src, int srcIndex)
{
int inputRowId = rowId;
for (int i = 0; i < count; i++) {
if (nullBitSet.get(inputRowId)) {
columnVector.putNull(inputRowId);
if (nullBitSet.get(rowId)) {
columnVector.putNull(rowId);
}
else {
columnVector.putLong(inputRowId, src[i]);
columnVector.putLong(rowId, src[i]);
}
inputRowId++;
rowId++;
}
}
@Override
public void putDoubles(int rowId, int count, double[] src, int srcIndex)
{
int inputRowId = rowId;
for (int i = 0; i < count; i++) {
if (nullBitSet.get(inputRowId)) {
columnVector.putNull(inputRowId);
if (nullBitSet.get(rowId)) {
columnVector.putNull(rowId);
}
else {
columnVector.putDouble(inputRowId, src[i]);
columnVector.putDouble(rowId, src[i]);
}
inputRowId++;
rowId++;
}
}
@Override
public void putBytes(int rowId, int count, byte[] src, int srcIndex)
{
int inputRowId = rowId;
for (int i = 0; i < count; i++) {
if (nullBitSet.get(inputRowId)) {
columnVector.putNull(inputRowId);
if (nullBitSet.get(rowId)) {
columnVector.putNull(rowId);
}
else {
columnVector.putByte(inputRowId, src[i]);
columnVector.putByte(rowId, src[i]);
}
inputRowId++;
rowId++;
}
}

View File

@ -56,10 +56,7 @@ import org.apache.hadoop.mapreduce.Job;
import org.apache.log4j.Logger;
import org.apache.thrift.TBase;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.attribute.BasicFileAttributes;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
@ -142,19 +139,10 @@ public class CarbondataTableReader
carbonTableCacheModel.getCarbonTable().isTransactionalTable()) {
CarbonTable carbonTable = carbonTableCacheModel.getCarbonTable();
try {
String schemaFilePath = CarbonTablePath
.getSchemaFilePath(
carbonTable.getTablePath());
FileFactory.FileType fileType = FileFactory.getFileType(schemaFilePath);
CarbonFile carbonFile = FileFactory.getCarbonFile(schemaFilePath,
config);
long latestTime = carbonFile.getLastModifiedTime();
// Workaround for cache updation error due to round off of latestTime inside LocalCarbonFile
if (fileType == FileFactory.FileType.LOCAL) {
latestTime = Files.readAttributes(new File(schemaFilePath).toPath(), BasicFileAttributes.class).lastModifiedTime().toMillis();
}
long latestTime = FileFactory.getCarbonFile(CarbonTablePath
.getSchemaFilePath(
carbonTable.getTablePath()),
config).getLastModifiedTime();
carbonTableCacheModel.setCurrentSchemaTime(latestTime);
if (!carbonTableCacheModel.isValid()) {
// Invalidate datamaps
@ -162,7 +150,7 @@ public class CarbondataTableReader
.clearIndex(carbonTableCacheModel.getCarbonTable().getAbsoluteTableIdentifier());
}
}
catch (CarbonFileException | IOException e) {
catch (CarbonFileException e) {
carbonCache.get().remove(schemaTableName);
}
}
@ -223,11 +211,6 @@ public class CarbondataTableReader
tableInfo = (org.apache.carbondata.format.TableInfo) thriftReader.read();
thriftReader.close();
modifiedTime = schemaFile.getLastModifiedTime();
FileFactory.FileType fileType = FileFactory.getFileType(schemaFilePath);
// Workaround for cache updation error due to round off of latesttime inside LocalCarbonFile
if (fileType == FileFactory.FileType.LOCAL) {
modifiedTime = Files.readAttributes(new File(schemaFilePath).toPath(), BasicFileAttributes.class).lastModifiedTime().toMillis();
}
}
else {
tableInfo = CarbonUtil.inferSchema(tablePath, table.getTableName(), false, config);
@ -340,7 +323,7 @@ public class CarbondataTableReader
inputSplits.get(j).stream().flatMap(f -> Arrays.stream(getLocations(f))).distinct()
.toArray(String[]::new)));
}
LOGGER.error("Size of MultiblockList " + multiBlockSplitList.size());
LOGGER.error("Size fo MultiblockList " + multiBlockSplitList.size());
}
}
catch (IOException e) {

View File

@ -58,9 +58,8 @@ public class BooleanStreamReader
@Override
public void putBytes(int rowId, int count, byte[] src, int srcIndex)
{
int srcIdx = srcIndex;
for (int i = 0; i < count; i++) {
type.writeBoolean(builder, src[srcIdx++] == 1);
type.writeBoolean(builder, src[srcIndex++] == 1);
}
}

View File

@ -76,9 +76,8 @@ public class DecimalSliceStreamReader
@Override
public void putDecimals(int rowId, int count, BigDecimal value, int precision)
{
int id = rowId;
for (int i = 0; i < count; i++) {
putDecimal(id++, value, precision);
putDecimal(rowId++, value, precision);
}
}

View File

@ -58,9 +58,8 @@ public class IntegerStreamReader
@Override
public void putInts(int rowId, int count, int value)
{
int id = rowId;
for (int i = 0; i < count; i++) {
putInt(id++, value);
putInt(rowId++, value);
}
}

View File

@ -40,7 +40,6 @@ import java.util.List;
import java.util.Map;
import static org.testng.Assert.assertTrue;
import static org.testng.AssertJUnit.assertNotNull;
public class TestCarbonAutoVacuum
{
@ -100,6 +99,7 @@ public class TestCarbonAutoVacuum
@AfterClass
public void tearDown() throws SQLException, IOException, InterruptedException
{
//hetuServer.execute("drop table if exists hive.default.demotable");
logger.info("TearDown begin: " + this.getClass().getSimpleName());
hetuServer.stopServer();
CarbonUtil.deleteFoldersAndFiles(FileFactory.getCarbonFile(storePath));
@ -145,12 +145,11 @@ public class TestCarbonAutoVacuum
try {
CarbondataAutoVacuumThread.enableTracingVacuumTask(true);
assertNotNull(catalog);
connector = catalog.getConnector(catalog.getConnectorCatalogName());
connectorMetadata = connector.getConnectorMetadata();
connectorMetadata.getTablesForVacuum();
} catch (Exception e) {
logger.debug(e.getMessage());
}
CarbondataAutoVacuumThread.waitForSubmittedVacuumTasksFinish();
@ -216,7 +215,7 @@ public class TestCarbonAutoVacuum
connectorMetadata = connector.getConnectorMetadata();
connectorMetadata.getTablesForVacuum();
} catch (Exception e) {
logger.debug(e.getMessage());
}
CarbondataAutoVacuumThread.waitForSubmittedVacuumTasksFinish();

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2021. Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (C) 2018-2020. Huawei Technologies Co., Ltd. All rights reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@ -62,6 +62,7 @@ public class TestCarbondataAutoCleanup
public void setup() throws Exception
{
logger.info("Setup begin: " + this.getClass().getSimpleName());
String dataPath = rootPath + "/src/test/resources/alldatatype.csv";
CarbonProperties.getInstance().addProperty(CarbonCommonConstants.CARBON_WRITTEN_BY_APPNAME, "HetuTest");
CarbonProperties.getInstance().addProperty(CarbonCommonConstants.MAX_QUERY_EXECUTION_TIME, "0");
@ -89,7 +90,6 @@ public class TestCarbondataAutoCleanup
hetuServer.execute("drop table if exists testdb.testtableautocleanup6");
hetuServer.execute("drop table if exists testdb.testtableautocleanup7");
hetuServer.execute("drop table if exists testdb.testtableautocleanup8");
hetuServer.execute("drop table if exists testdb.testtableautocleanupwithpushdown");
hetuServer.execute("drop schema if exists testdb");
hetuServer.execute("drop schema if exists default");
hetuServer.execute("create schema testdb");
@ -130,7 +130,7 @@ public class TestCarbondataAutoCleanup
assertEquals(FileFactory.isFileExist(storePath + "/carbon.store/testdb/testtableautocleanup1/Fact/Part0/Segment_3", false), false);
}
catch (IOException exception) {
logger.debug(exception.getMessage());
}
CarbondataMetadata.enableTracingCleanupTask(false);
@ -159,7 +159,7 @@ public class TestCarbondataAutoCleanup
assertEquals(FileFactory.isFileExist(storePath + "/carbon.store/testdb/testtableautocleanup2/Fact/Part0/Segment_2", false), false);
assertEquals(FileFactory.isFileExist(storePath + "/carbon.store/testdb/testtableautocleanup2/Fact/Part0/Segment_3", false), false);
} catch (IOException exception) {
logger.debug(exception.getMessage());
}
CarbondataMetadata.enableTracingCleanupTask(false);
@ -189,7 +189,7 @@ public class TestCarbondataAutoCleanup
assertEquals(FileFactory.isFileExist(storePath + "/carbon.store/testdb/testtableautocleanup3/Fact/Part0/Segment_2", false), false);
assertEquals(FileFactory.isFileExist(storePath + "/carbon.store/testdb/testtableautocleanup3/Fact/Part0/Segment_3", false), false);
} catch (IOException exception) {
logger.debug(exception.getMessage());
}
CarbondataMetadata.enableTracingCleanupTask(false);
@ -201,32 +201,32 @@ public class TestCarbondataAutoCleanup
{
try {
hetuServer.execute("set session carbondata.orc_predicate_pushdown_enabled = true");
hetuServer.execute("drop table if exists testdb.testtableautocleanupwithpushdown");
hetuServer.execute("CREATE TABLE testdb.testtableautocleanupwithpushdown (a int, b int)");
hetuServer.execute("INSERT INTO testdb.testtableautocleanupwithpushdown VALUES (10, 11)");
hetuServer.execute("INSERT INTO testdb.testtableautocleanupwithpushdown VALUES (110, 211)");
hetuServer.execute("INSERT INTO testdb.testtableautocleanupwithpushdown VALUES (120, 311)");
hetuServer.execute("INSERT INTO testdb.testtableautocleanupwithpushdown VALUES (130, 411)");
hetuServer.execute("INSERT INTO testdb.testtableautocleanupwithpushdown VALUES (130, 511)");
hetuServer.execute("vacuum table testdb.testtableautocleanupwithpushdown AND WAIT");
hetuServer.execute("drop table if exists testdb.testtableautocleanup3");
hetuServer.execute("CREATE TABLE testdb.testtableautocleanup3 (a int, b int)");
hetuServer.execute("INSERT INTO testdb.testtableautocleanup3 VALUES (10, 11)");
hetuServer.execute("INSERT INTO testdb.testtableautocleanup3 VALUES (110, 211)");
hetuServer.execute("INSERT INTO testdb.testtableautocleanup3 VALUES (120, 311)");
hetuServer.execute("INSERT INTO testdb.testtableautocleanup3 VALUES (130, 411)");
hetuServer.execute("INSERT INTO testdb.testtableautocleanup3 VALUES (130, 511)");
hetuServer.execute("vacuum table testdb.testtableautocleanup3 AND WAIT");
reduceModificationOrdeletionTimesStamp(storePath + "/carbon.store/testdb/testtableautocleanupwithpushdown/Metadata");
reduceModificationOrdeletionTimesStamp(storePath + "/carbon.store/testdb/testtableautocleanup3/Metadata");
CarbondataMetadata.enableTracingCleanupTask(true);
hetuServer.execute("DELETE FROM testdb.testtableautocleanupwithpushdown WHERE a=130");
hetuServer.execute("DELETE FROM testdb.testtableautocleanup3 WHERE a=130");
try {
CarbondataMetadata.waitForSubmittedTasksFinish();
assertEquals(FileFactory.isFileExist(storePath + "/carbon.store/testdb/testtableautocleanupwithpushdown/Fact/Part0/Segment_0", false), false);
assertEquals(FileFactory.isFileExist(storePath + "/carbon.store/testdb/testtableautocleanupwithpushdown/Fact/Part0/Segment_1", false), false);
assertEquals(FileFactory.isFileExist(storePath + "/carbon.store/testdb/testtableautocleanupwithpushdown/Fact/Part0/Segment_2", false), false);
assertEquals(FileFactory.isFileExist(storePath + "/carbon.store/testdb/testtableautocleanupwithpushdown/Fact/Part0/Segment_3", false), false);
assertEquals(FileFactory.isFileExist(storePath + "/carbon.store/testdb/testtableautocleanup3/Fact/Part0/Segment_0", false), false);
assertEquals(FileFactory.isFileExist(storePath + "/carbon.store/testdb/testtableautocleanup3/Fact/Part0/Segment_1", false), false);
assertEquals(FileFactory.isFileExist(storePath + "/carbon.store/testdb/testtableautocleanup3/Fact/Part0/Segment_2", false), false);
assertEquals(FileFactory.isFileExist(storePath + "/carbon.store/testdb/testtableautocleanup3/Fact/Part0/Segment_3", false), false);
} catch (IOException exception) {
logger.debug(exception.getMessage());
}
}
finally {
CarbondataMetadata.enableTracingCleanupTask(false);
hetuServer.execute("drop table testdb.testtableautocleanupwithpushdown");
hetuServer.execute("drop table testdb.testtableautocleanup3");
hetuServer.execute("set session carbondata.orc_predicate_pushdown_enabled = false");
}
}
@ -254,7 +254,7 @@ public class TestCarbondataAutoCleanup
assertEquals(FileFactory.isFileExist(storePath + "/carbon.store/testdb/testtableautocleanup4/Fact/Part0/Segment_2", false), false);
assertEquals(FileFactory.isFileExist(storePath + "/carbon.store/testdb/testtableautocleanup4/Fact/Part0/Segment_3", false), false);
} catch (IOException exception) {
logger.debug(exception.getMessage());
}
CarbondataMetadata.enableTracingCleanupTask(false);
@ -285,7 +285,7 @@ public class TestCarbondataAutoCleanup
assertEquals(FileFactory.isFileExist(storePath + "/carbon.store/testdb/testtableautocleanup5/Fact/Part0/Segment_3", false), false);
}
catch (IOException exception) {
logger.debug(exception.getMessage());
}
CarbondataMetadata.enableTracingCleanupTask(false);
@ -314,7 +314,7 @@ public class TestCarbondataAutoCleanup
assertEquals(FileFactory.isFileExist(storePath + "/carbon.store/testdb/testtableautocleanup6/Fact/Part0/Segment_2", false), false);
assertEquals(FileFactory.isFileExist(storePath + "/carbon.store/testdb/testtableautocleanup6/Fact/Part0/Segment_3", false), false);
} catch (IOException exception) {
logger.debug(exception.getMessage());
}
CarbondataMetadata.enableTracingCleanupTask(false);
@ -344,7 +344,7 @@ public class TestCarbondataAutoCleanup
assertEquals(FileFactory.isFileExist(storePath + "/carbon.store/testdb/testtableautocleanup7/Fact/Part0/Segment_2", false), false);
assertEquals(FileFactory.isFileExist(storePath + "/carbon.store/testdb/testtableautocleanup7/Fact/Part0/Segment_3", false), false);
} catch (IOException exception) {
logger.debug(exception.getMessage());
}
CarbondataMetadata.enableTracingCleanupTask(false);
@ -374,7 +374,7 @@ public class TestCarbondataAutoCleanup
assertEquals(FileFactory.isFileExist(storePath + "/carbon.store/testdb/testtableautocleanup8/Fact/Part0/Segment_2", false), false);
assertEquals(FileFactory.isFileExist(storePath + "/carbon.store/testdb/testtableautocleanup8/Fact/Part0/Segment_3", false), false);
} catch (IOException exception) {
logger.debug(exception.getMessage());
}
CarbondataMetadata.enableTracingCleanupTask(false);
@ -403,7 +403,7 @@ public class TestCarbondataAutoCleanup
content = content.replaceFirst(modificationOrdeletionTimesStamp, replace);
Files.write(path, content.getBytes(charset));
} catch (IOException e) {
logger.error(e.getMessage());
e.printStackTrace();
}
}
}

View File

@ -99,7 +99,7 @@ public class TestCarbondataMinorConfig
"/carbon.store/mytestdb/mytesttable/Fact/Part0/Segment_0.1", false), true);
} catch (IOException e) {
hetuServer.execute("DROP TABLE if exists mytestdb.mytesttable");
logger.error(e.getMessage());
e.printStackTrace();
}
hetuServer.execute("DROP TABLE if exists mytestdb.mytesttable");

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2021. Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (C) 2018-2020. Huawei Technologies Co., Ltd. All rights reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@ -15,7 +15,6 @@
package io.hetu.core.plugin.carbondata.integrationtest;
import io.airlift.log.Logger;
import io.hetu.core.plugin.carbondata.server.HetuTestServer;
import org.apache.carbondata.core.constants.CarbonCommonConstants;
import org.apache.carbondata.core.datastore.impl.FileFactory;
@ -37,7 +36,6 @@ import static org.testng.Assert.assertTrue;
public class TestsWithHiveConnector
{
private static final Logger log = Logger.get(TestsWithHiveConnector.class);
private String rootPath = new File(this.getClass().getResource("/").getPath() + "../..")
.getCanonicalPath();
@ -116,7 +114,7 @@ public class TestsWithHiveConnector
assertEquals(FileFactory.isFileExist(storePath +
"hive.store/default/parttable/year=2013", false), false);
} catch (IOException exception) {
log.error(exception.getMessage());
exception.printStackTrace();
}
hetuServer.execute("DROP TABLE hive.default.parttable");
}
@ -125,37 +123,37 @@ public class TestsWithHiveConnector
public void deleteTransactionTableDirUsing2tables()
throws SQLException
{
hetuServer.execute("drop table if exists hive.default.parttable2");
hetuServer.execute("drop table if exists hive.default.parttable");
hetuServer.execute("drop table if exists hive.default.parttable1");
hetuServer.execute("set session DELETE_TRANSACTIONAL_TABLE_DIRECT = true");
hetuServer.execute("create table hive.default.parttable2 (orderkey int, year int) WITH (transactional = true , format = 'ORC', partitioned_by = ARRAY[ 'year' ] )");
hetuServer.execute("insert into hive.default.parttable2 values (1,2011)");
hetuServer.execute("insert into hive.default.parttable2 values (2,2012)");
hetuServer.execute("insert into hive.default.parttable2 values (3,2013)");
hetuServer.execute("create table hive.default.parttable (orderkey int, year int) WITH (transactional = true , format = 'ORC', partitioned_by = ARRAY[ 'year' ] )");
hetuServer.execute("insert into hive.default.parttable values (1,2011)");
hetuServer.execute("insert into hive.default.parttable values (2,2012)");
hetuServer.execute("insert into hive.default.parttable values (3,2013)");
hetuServer.execute("create table hive.default.parttable1 (orderkey int, year int) WITH (transactional = true , format = 'ORC', partitioned_by = ARRAY[ 'year' ] )");
hetuServer.execute("insert into hive.default.parttable1 values (1,2011)");
hetuServer.execute("insert into hive.default.parttable1 values (2,2012)");
hetuServer.execute("insert into hive.default.parttable1 values (3,2013)");
hetuServer.execute("delete from hive.default.parttable2 where year >= (select max(year) from hive.default.parttable1) ");
hetuServer.execute("delete from hive.default.parttable where year >= (select max(year) from hive.default.parttable1) ");
try {
assertEquals(FileFactory.isFileExist(storePath +
"hive.store/default/parttable2/year=2013", false), false);
"hive.store/default/parttable/year=2013", false), false);
} catch (IOException exception) {
log.error(exception.getMessage());
exception.printStackTrace();
}
hetuServer.execute("insert into hive.default.parttable2 values (4,2014)");
hetuServer.execute("delete from hive.default.parttable2 where year >= (select year from hive.default.parttable1 where orderkey=4 ) ");
hetuServer.execute("insert into hive.default.parttable values (4,2014)");
hetuServer.execute("delete from hive.default.parttable where year >= (select year from hive.default.parttable1 where orderkey=4 ) ");
try {
assertEquals(FileFactory.isFileExist(storePath +
"hive.store/default/parttable2/year=2014", false), false);
"hive.store/default/parttable/year=2014", false), false);
} catch (IOException exception) {
log.error(exception.getMessage());
exception.printStackTrace();
}
hetuServer.execute("DROP TABLE hive.default.parttable2");
hetuServer.execute("DROP TABLE hive.default.parttable");
hetuServer.execute("DROP TABLE hive.default.parttable1");
}
@ -163,72 +161,46 @@ public class TestsWithHiveConnector
public void deleteTransactionTableDirDisable()
throws SQLException
{
hetuServer.execute("drop table if exists hive.default.parttable3");
hetuServer.execute("drop table if exists hive.default.parttable");
hetuServer.execute("set session DELETE_TRANSACTIONAL_TABLE_DIRECT = false");
hetuServer.execute("create table hive.default.parttable3 (orderkey int, year int) WITH (transactional = true , format = 'ORC', partitioned_by = ARRAY[ 'year' ] )");
hetuServer.execute("insert into hive.default.parttable3 values (1,2011)");
hetuServer.execute("insert into hive.default.parttable3 values (2,2012)");
hetuServer.execute("insert into hive.default.parttable3 values (3,2013)");
hetuServer.execute("create table hive.default.parttable (orderkey int, year int) WITH (transactional = true , format = 'ORC', partitioned_by = ARRAY[ 'year' ] )");
hetuServer.execute("insert into hive.default.parttable values (1,2011)");
hetuServer.execute("insert into hive.default.parttable values (2,2012)");
hetuServer.execute("insert into hive.default.parttable values (3,2013)");
hetuServer.execute("create table hive.default.parttable4 (orderkey int, year int) WITH (transactional = true , format = 'ORC', partitioned_by = ARRAY[ 'year' ] )");
hetuServer.execute("insert into hive.default.parttable4 values (1,2011)");
hetuServer.execute("insert into hive.default.parttable4 values (2,2012)");
hetuServer.execute("insert into hive.default.parttable4 values (3,2013)");
hetuServer.execute("create table hive.default.parttable1 (orderkey int, year int) WITH (transactional = true , format = 'ORC', partitioned_by = ARRAY[ 'year' ] )");
hetuServer.execute("insert into hive.default.parttable1 values (1,2011)");
hetuServer.execute("insert into hive.default.parttable1 values (2,2012)");
hetuServer.execute("insert into hive.default.parttable1 values (3,2013)");
hetuServer.execute("delete from hive.default.parttable3 where year >= (select max(year) from hive.default.parttable4) ");
hetuServer.execute("delete from hive.default.parttable where year >= (select max(year) from hive.default.parttable1) ");
try {
assertEquals(FileFactory.isFileExist(storePath +
"/hive.store/default/parttable3/year=2013", false), true);
"/hive.store/default/parttable/year=2013", false), true);
} catch (IOException exception) {
log.error(exception.getMessage());
exception.printStackTrace();
}
hetuServer.execute("DROP TABLE hive.default.parttable3");
hetuServer.execute("DROP TABLE hive.default.parttable");
}
@Test(dependsOnMethods = {"block_Hive_Table_from_Carbondata"})
public void block_Carbondata_Table_from_Hive()
throws SQLException
{
hetuServer.execute("CREATE TABLE carbondata.default.demotable1 (c1 int)");
hetuServer.execute("CREATE TABLE carbondata.default.demotable (c1 int)");
hetuServer.execute("use hive.default");
runQueryAndAssertErrorMessage("SELECT * FROM demotable1",
runQueryAndAssertErrorMessage("SELECT * FROM demotable",
"Hive connector can't read carbondata tables");
runQueryAndAssertErrorMessage("INSERT INTO demotable1 VALUES(1)",
runQueryAndAssertErrorMessage("INSERT INTO demotable VALUES(1)",
"Tables with MapredCarbonInputFormat are not supported by Hive connector");
runQueryAndAssertErrorMessage("UPDATE demotable1 SET c1=1",
runQueryAndAssertErrorMessage("UPDATE demotable SET c1=1",
"Tables with MapredCarbonInputFormat are not supported by Hive connector");
hetuServer.execute("use carbondata.default");
hetuServer.execute("DROP TABLE carbondata.default.demotable1");
}
@Test(dependsOnMethods = {"block_Hive_Table_from_Carbondata"})
public void block_Carbondata_Table_change_from_Hive()
throws SQLException
{
hetuServer.execute("CREATE TABLE carbondata.default.changetable (a int, b int, c int)");
hetuServer.execute("use hive.default");
//rename column
runQueryAndAssertErrorMessage("ALTER TABLE default.changetable RENAME COLUMN a TO aa",
"Tables with MapredCarbonInputFormat are not supported by Hive connector");
//add column
runQueryAndAssertErrorMessage("ALTER TABLE default.changetable ADD COLUMN e int COMMENT 'Hello World'",
"Tables with MapredCarbonInputFormat are not supported by Hive connector");
//drop column
runQueryAndAssertErrorMessage("ALTER TABLE hive.default.changetable DROP COLUMN c",
"Tables with MapredCarbonInputFormat are not supported by Hive connector");
//change table name
runQueryAndAssertErrorMessage("ALTER TABLE hive.default.changetable RENAME TO hive.default.changetable_N",
"Tables with MapredCarbonInputFormat are not supported by Hive connector");
//drop table
runQueryAndAssertErrorMessage("DROP TABLE default.changetable",
"Tables with MapredCarbonInputFormat are not supported by Hive connector");
hetuServer.execute("use carbondata.default");
hetuServer.execute("DROP TABLE carbondata.default.changetable");
hetuServer.execute("DROP TABLE hive.default.demotable");
}
private Map<String, String> createHiveProperties()
@ -237,11 +209,6 @@ public class TestsWithHiveConnector
hiveProperties.put("hive.metastore", "file");
hiveProperties.put("hive.allow-drop-table", "true");
hiveProperties.put("hive.non-managed-table-writes-enabled", "true");
hiveProperties.put("hive.allow-add-column", "true");
hiveProperties.put("hive.allow-drop-column", "true");
hiveProperties.put("hive.allow-rename-table", "true");
hiveProperties.put("hive.allow-comment-table", "true");
hiveProperties.put("hive.allow-rename-column", "true");
hiveProperties.put("hive.metastore.catalog.dir", "file://" + storePath + "/hive.store");
return hiveProperties;
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2021. Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (C) 2018-2020. Huawei Technologies Co., Ltd. All rights reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@ -91,11 +91,11 @@ public class HetuTestServer
carbonProperties.putAll(properties);
logger.info("------------ Starting Presto Server -------------");
DistributedQueryRunner distributedQueryRunner = createQueryRunner(hetuProperties);
DistributedQueryRunner queryRunner = createQueryRunner(hetuProperties);
Connection connection = createJdbcConnection(dbName);
statement = (PrestoStatement) connection.createStatement();
logger.info("STARTED SERVER AT :" + distributedQueryRunner.getCoordinator().getBaseUrl());
logger.info("STARTED SERVER AT :" + queryRunner.getCoordinator().getBaseUrl());
}
public void stopServer() throws SQLException
@ -123,20 +123,14 @@ public class HetuTestServer
public List<Map<String, Object>> executeQuery(String query) throws SQLException
{
logger.info(">>>>> Executing Query: " + query);
ResultSet rs = null;
try {
rs = statement.executeQuery(query);
ResultSet rs = statement.executeQuery(query);
return convertResultSetToList(rs);
}
catch (SQLException e) {
logger.error("Exception Occured: " + e.getMessage() + "\n Failed Query: " + query);
throw e;
}
finally {
if (rs != null) {
rs.close();
}
}
}
private List<Map<String, Object>> convertResultSetToList(ResultSet rs) throws SQLException
@ -192,7 +186,7 @@ public class HetuTestServer
{
try {
queryRunner.installPlugin(new CarbondataPlugin());
Map<String, String> carbonPropertiesMap = ImmutableMap.<String, String>builder()
Map<String, String> carbonProperties = ImmutableMap.<String, String>builder()
.putAll(this.carbonProperties)
.put("carbon.unsafe.working.memory.in.mb", "512")
.build();
@ -203,7 +197,7 @@ public class HetuTestServer
.build();
// CreateCatalog will create a catalog for CarbonData in etc/catalog.
queryRunner.createCatalog(carbonDataCatalog, carbonDataConnector, carbonPropertiesMap);
queryRunner.createCatalog(carbonDataCatalog, carbonDataConnector, carbonProperties);
queryRunner.createCatalog(carbonDataCatalogLocationDisabled, carbonDataConnector, carbonPropertiesLocationDisabled);
}
catch (RuntimeException e) {

View File

@ -5,7 +5,7 @@
<parent>
<groupId>io.hetu.core</groupId>
<artifactId>presto-root</artifactId>
<version>1.7.0-SNAPSHOT</version>
<version>1.3.1-SNAPSHOT</version>
</parent>
<artifactId>hetu-clickhouse</artifactId>

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2021. Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (C) 2018-2020. Huawei Technologies Co., Ltd. All rights reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@ -61,7 +61,6 @@ import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.sql.Types;
import java.text.SimpleDateFormat;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
@ -289,40 +288,6 @@ public class ClickHouseClient
}
}
@Override
public long getTableModificationTime(ConnectorSession session, JdbcTableHandle handle)
{
String sql = format(
"SELECT max(modification_time) as modified_time FROM system.parts WHERE database='%s' and table='%s'",
handle.getSchemaTableName().getSchemaName(),
handle.getSchemaTableName().getTableName());
try (Connection connection = connectionFactory.openConnection(JdbcIdentity.from(session));
PreparedStatement preparedStatement = getPreparedStatement(connection, sql)) {
ResultSet resultSet = preparedStatement.executeQuery();
if (resultSet.next()) {
String updateTime = resultSet.getString("modified_time");
SimpleDateFormat parser = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
return parser.parse(updateTime).getTime();
}
else {
// In the case where for some reason the table doesn't exist anymore in system.parts
return -1L;
}
}
catch (Exception e) {
// We want to make sure the query doesn't fail because of star-tree not being able to get last modified time
logger.error("Exception thrown while trying to get modified time", e);
return -1L;
}
}
@Override
public boolean isPreAggregationSupported(ConnectorSession session)
{
return true;
}
@Override
protected void renameTable(JdbcIdentity identity, String catalogName, String schemaName, String tableName, SchemaTableName newTable)
{
@ -345,9 +310,8 @@ public class ClickHouseClient
}
@Override
public void renameColumn(JdbcIdentity identity, JdbcTableHandle handle, JdbcColumnHandle jdbcColumn, String inputNewColumnName)
public void renameColumn(JdbcIdentity identity, JdbcTableHandle handle, JdbcColumnHandle jdbcColumn, String newColumnName)
{
String newColumnName = inputNewColumnName;
try (Connection connection = connectionFactory.openConnection(identity)) {
if (connection.getMetaData().storesUpperCaseIdentifiers()) {
newColumnName = newColumnName.toUpperCase(ENGLISH);

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2021. Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (C) 2018-2020. Huawei Technologies Co., Ltd. All rights reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2021. Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (C) 2018-2020. Huawei Technologies Co., Ltd. All rights reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2021. Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (C) 2018-2020. Huawei Technologies Co., Ltd. All rights reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2021. Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (C) 2018-2020. Huawei Technologies Co., Ltd. All rights reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@ -14,23 +14,8 @@
*/
package io.hetu.core.plugin.clickhouse;
import io.prestosql.plugin.jdbc.BaseJdbcConfig;
import io.prestosql.plugin.jdbc.JdbcPlugin;
import io.prestosql.spi.function.ConnectorConfig;
import io.prestosql.spi.queryeditorui.ConnectorUtil;
import io.prestosql.spi.queryeditorui.ConnectorWithProperties;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Optional;
@ConnectorConfig(connectorLabel = "Clickhouse: Query data in Clickhouse system",
propertiesEnabled = true,
catalogConfigFilesEnabled = true,
globalConfigFilesEnabled = true,
docLink = "https://openlookeng.io/docs/docs/connector/clickhouse.html",
configLink = "https://openlookeng.io/docs/docs/connector/clickhouse.html#configuration")
public class ClickHousePlugin
extends JdbcPlugin
{
@ -38,14 +23,4 @@ public class ClickHousePlugin
{
super("clickhouse", new ClickHouseClientModule());
}
@Override
public Optional<ConnectorWithProperties> getConnectorWithProperties()
{
ConnectorConfig connectorConfig = ClickHousePlugin.class.getAnnotation(ConnectorConfig.class);
ArrayList<Method> methods = new ArrayList<>();
methods.addAll(Arrays.asList(BaseJdbcConfig.class.getDeclaredMethods()));
methods.addAll(Arrays.asList(ClickHouseConfig.class.getDeclaredMethods()));
return ConnectorUtil.assembleConnectorProperties(connectorConfig, methods);
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2021. Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (C) 2018-2020. Huawei Technologies Co., Ltd. All rights reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2021. Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (C) 2018-2020. Huawei Technologies Co., Ltd. All rights reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@ -41,7 +41,6 @@ public class ClickHouseApplyRemoteFunctionPushDown
/**
* rewrite the remote function to a executable function in the data source.
*/
@Override
public Optional<String> rewriteRemoteFunction(CallExpression callExpression, BaseJdbcRowExpressionConverter rowExpressionConverter, JdbcConverterContext jdbcConverterContext)
{
if (!isConnectorSupportedRemoteFunction(callExpression)) {

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2021. Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (C) 2018-2020. Huawei Technologies Co., Ltd. All rights reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2021. Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (C) 2018-2020. Huawei Technologies Co., Ltd. All rights reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2021. Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (C) 2018-2020. Huawei Technologies Co., Ltd. All rights reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2021. Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (C) 2018-2020. Huawei Technologies Co., Ltd. All rights reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@ -37,9 +37,8 @@ public class ClickHouseSqlStatementWriter
}
@Override
public String aggregation(String inputFunctionName, List<String> arguments, boolean isDistinct)
public String aggregation(String functionName, List<String> arguments, boolean isDistinct)
{
String functionName = inputFunctionName;
if (functionName.toUpperCase(Locale.ENGLISH).equals("VARIANCE")) {
functionName = "varPop";
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2021. Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (C) 2018-2020. Huawei Technologies Co., Ltd. All rights reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2021. Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (C) 2018-2020. Huawei Technologies Co., Ltd. All rights reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2021. Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (C) 2018-2020. Huawei Technologies Co., Ltd. All rights reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2021. Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (C) 2018-2020. Huawei Technologies Co., Ltd. All rights reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2021. Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (C) 2018-2020. Huawei Technologies Co., Ltd. All rights reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2021. Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (C) 2018-2020. Huawei Technologies Co., Ltd. All rights reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2021. Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (C) 2018-2020. Huawei Technologies Co., Ltd. All rights reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2021. Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (C) 2018-2020. Huawei Technologies Co., Ltd. All rights reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2021. Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (C) 2018-2020. Huawei Technologies Co., Ltd. All rights reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2021. Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (C) 2018-2020. Huawei Technologies Co., Ltd. All rights reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2021. Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (C) 2018-2020. Huawei Technologies Co., Ltd. All rights reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2021. Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (C) 2018-2020. Huawei Technologies Co., Ltd. All rights reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@ -205,7 +205,7 @@ public final class ClickHouseServerTest
{
String actualTable = tablePattern;
for (String table : tables) {
for (String table : tables) { //tableName + _ + UUID
int lastIndex = table.lastIndexOf("_");
if (lastIndex == -1) {
continue;

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2021. Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (C) 2018-2020. Huawei Technologies Co., Ltd. All rights reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at

View File

@ -5,7 +5,7 @@
<parent>
<groupId>io.hetu.core</groupId>
<artifactId>presto-root</artifactId>
<version>1.7.0-SNAPSHOT</version>
<version>1.3.1-SNAPSHOT</version>
</parent>
<artifactId>hetu-common</artifactId>

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2021. Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (C) 2018-2020. Huawei Technologies Co., Ltd. All rights reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at

View File

@ -16,7 +16,6 @@ package io.hetu.core.common.util;
import java.io.File;
import java.io.IOException;
import java.nio.file.Path;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
@ -37,7 +36,6 @@ public class SecurePathWhiteList
/**
* Due to security concerns, all data must be read from one of the whitelisted paths
*
* @return
* @throws IOException
*/
@ -55,11 +53,6 @@ public class SecurePathWhiteList
return securePathwhiteList;
}
public static boolean isSecurePath(Path absolutePath) throws IOException
{
return isSecurePath(absolutePath.toString());
}
public static boolean isSecurePath(String absolutePath) throws IOException
{
// absolutePath

View File

@ -47,6 +47,16 @@ public class SslSocketUtil
if (!tlsEnabled) {
return Optional.empty();
}
// https://docs.oracle.com/javase/8/docs/technotes/guides/security/jsse/JSSERefGuide.html#CustomizingStores
// as per link above, the default SSLContext will be constructed using the default KeyManager and
// default TrustManager. Those can be configured using the following system properties:
// javax.net.ssl.keyStore
// javax.net.ssl.keyStorePassword
// javax.net.ssl.keyStoreType
// javax.net.ssl.trustStore
// javax.net.ssl.trustStorePassword
// see link above for more details
return Optional.of(SSLContext.getDefault());
}

View File

@ -13,7 +13,6 @@
*/
package io.hetu.core.common.util;
import io.airlift.log.Logger;
import io.airlift.security.pem.PemReader;
import javax.security.auth.x500.X500Principal;
@ -30,8 +29,6 @@ import java.util.Optional;
public class TrustStore
{
private static final Logger LOGGER = Logger.get(TrustStore.class);
private TrustStore() {}
public static KeyStore loadTrustStore(File trustStorePath, Optional<String> trustStorePassword)
@ -51,7 +48,6 @@ public class TrustStore
}
}
catch (IOException | GeneralSecurityException ignored) {
LOGGER.error("loadTrustStore error : %s", ignored.getMessage());
}
try (InputStream in = new FileInputStream(trustStorePath)) {

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2021. Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (C) 2018-2020. Huawei Technologies Co., Ltd. All rights reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at

View File

@ -34,9 +34,9 @@ public class TestTempFolder
root = folder.getRoot();
assertTrue(root.exists());
File newFile = folder.newFile("aNewFile");
assertEquals(newFile.getCanonicalPath(), folder.getRoot().getCanonicalPath() + "/aNewFile");
assertEquals(newFile.getAbsolutePath(), folder.getRoot().getAbsolutePath() + "/aNewFile");
File newFolder = folder.newFile("aNewFolder");
assertEquals(newFolder.getCanonicalPath(), folder.getRoot().getCanonicalPath() + "/aNewFolder");
assertEquals(newFolder.getAbsolutePath(), folder.getRoot().getAbsolutePath() + "/aNewFolder");
}
assertFalse(root.exists());
}

View File

@ -5,7 +5,7 @@
<parent>
<groupId>io.hetu.core</groupId>
<artifactId>presto-root</artifactId>
<version>1.7.0-SNAPSHOT</version>
<version>1.3.1-SNAPSHOT</version>
</parent>
<artifactId>hetu-cube</artifactId>

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2021. Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (C) 2018-2020. Huawei Technologies Co., Ltd. All rights reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at

View File

@ -36,7 +36,8 @@ public class CubeFilter
public CubeFilter(String sourceTablePredicate)
{
this(sourceTablePredicate, null);
this.sourceTablePredicate = sourceTablePredicate;
this.cubePredicate = null;
}
public String getSourceTablePredicate()

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2021. Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (C) 2018-2020. Huawei Technologies Co., Ltd. All rights reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2021. Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (C) 2018-2020. Huawei Technologies Co., Ltd. All rights reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2021. Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (C) 2018-2020. Huawei Technologies Co., Ltd. All rights reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@ -140,13 +140,13 @@ public class CubeStatement
return this;
}
public Builder groupByAddString(String column)
public Builder groupBy(String column)
{
this.groupBy.add(column);
return this;
}
public Builder groupByAddStringList(String... columns)
public Builder groupBy(String... columns)
{
this.groupBy.addAll(Arrays.asList(columns));
return this;

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2021. Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (C) 2018-2020. Huawei Technologies Co., Ltd. All rights reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2021. Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (C) 2018-2020. Huawei Technologies Co., Ltd. All rights reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2021. Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (C) 2018-2020. Huawei Technologies Co., Ltd. All rights reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2021. Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (C) 2018-2020. Huawei Technologies Co., Ltd. All rights reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@ -34,8 +34,8 @@ public class TestCubeStatement
.select("name", "address", "nationkey")
.aggregate(AggregationSignature.count())
.from("tpch.tiny.customer")
.groupByAddString("address")
.groupByAddStringList("name", "nationkey")
.groupBy("address")
.groupBy("name", "nationkey")
.build();
assertEquals(statement.getFrom(), "tpch.tiny.customer", "incorrect from table");

View File

@ -4,7 +4,7 @@
<parent>
<groupId>io.hetu.core</groupId>
<artifactId>presto-root</artifactId>
<version>1.7.0-SNAPSHOT</version>
<version>1.3.1-SNAPSHOT</version>
</parent>
<artifactId>hetu-datacenter</artifactId>

View File

@ -55,7 +55,6 @@ public final class DataCenterColumnHandle
}
@JsonProperty
@Override
public String getColumnName()
{
return columnName;

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2021. Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (C) 2018-2020. Huawei Technologies Co., Ltd. All rights reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2021. Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (C) 2018-2020. Huawei Technologies Co., Ltd. All rights reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2021. Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (C) 2018-2020. Huawei Technologies Co., Ltd. All rights reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2021. Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (C) 2018-2020. Huawei Technologies Co., Ltd. All rights reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2021. Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (C) 2018-2020. Huawei Technologies Co., Ltd. All rights reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2021. Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (C) 2018-2020. Huawei Technologies Co., Ltd. All rights reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2021. Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (C) 2018-2020. Huawei Technologies Co., Ltd. All rights reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@ -56,11 +56,11 @@ public final class DataCenterTableHandle
*/
public DataCenterTableHandle(String catalogName, String schemaName, String tableName, OptionalLong limit)
{
this(catalogName,
requireNonNull(schemaName, "schemaName is null"),
requireNonNull(tableName, "tableName is null"),
requireNonNull(limit, "limit is null"),
"");
this.catalogName = catalogName;
this.schemaName = requireNonNull(schemaName, "schemaName is null");
this.tableName = requireNonNull(tableName, "tableName is null");
this.limit = requireNonNull(limit, "limit is null");
this.pushDownSql = "";
}
/**
@ -125,7 +125,6 @@ public final class DataCenterTableHandle
return new SchemaTableName(schemaName, tableName);
}
@Override
public String getSchemaPrefixedTableName()
{
return catalogName + SPLIT_DOT + schemaName + SPLIT_DOT + tableName;

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2021. Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (C) 2018-2020. Huawei Technologies Co., Ltd. All rights reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@ -179,7 +179,7 @@ public class DataCenterPlanOptimizer
List<RowExpression> pushable = new ArrayList<>();
List<RowExpression> nonPushable = new ArrayList<>();
for (RowExpression conjunct : LogicalRowExpressions.extractConjuncts(node.getPredicate())) {
for (RowExpression conjunct : logicalRowExpressions.extractConjuncts(node.getPredicate())) {
try {
conjunct.accept(queryGenerator.getConverter(), new JdbcConverterContext());
pushable.add(conjunct);

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2021. Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (C) 2018-2020. Huawei Technologies Co., Ltd. All rights reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@ -116,20 +116,6 @@ public class DataCenterQueryGenerator
.setSchemaTableName(Optional.of(new SchemaTableName(dcTableHandle.getSchemaName(), dcTableHandle.getTableName())))
.setSelections(selections)
.setFrom(Optional.of(table.toString()));
String catalogName = dcTableHandle.getCatalogName();
if (catalogName != null) {
contextBuilder.setRemoteCatalogName(catalogName);
}
String schemaName = dcTableHandle.getSchemaName();
if (schemaName != null) {
contextBuilder.setRemoteSchemaName(schemaName);
}
String tableName = dcTableHandle.getTableName();
if (tableName != null) {
contextBuilder.setRemoteTablename(tableName);
}
// If LIMIT has been push down, add it to context
if (dcTableHandle.getLimit().isPresent()) {
contextBuilder.setLimit(dcTableHandle.getLimit());

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2021. Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (C) 2018-2020. Huawei Technologies Co., Ltd. All rights reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2021. Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (C) 2018-2020. Huawei Technologies Co., Ltd. All rights reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2021. Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (C) 2018-2020. Huawei Technologies Co., Ltd. All rights reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@ -1392,24 +1392,24 @@ public class TestCrossRegionDynamicFilter
hetuServer.installPlugin(new StateStoreManagerPlugin());
hetuServer.loadStateSotre();
DistributedQueryRunner distributedQueryRunner = null;
DistributedQueryRunner queryRunner = null;
try {
distributedQueryRunner = DistributedQueryRunner.builder(testSessionBuilder().build())
queryRunner = DistributedQueryRunner.builder(testSessionBuilder().build())
.setNodeCount(1)
.build();
Map<String, String> connectorProperties = new HashMap<>(properties);
connectorProperties.putIfAbsent("connection-url", hetuServer.getBaseUrl().toString());
connectorProperties.putIfAbsent("connection-user", "root");
distributedQueryRunner.installPlugin(new DataCenterPlugin());
distributedQueryRunner.createDCCatalog("dc", "dc", connectorProperties);
distributedQueryRunner.installPlugin(new TpchPlugin());
distributedQueryRunner.createCatalog("tpch", "tpch", properties);
queryRunner.installPlugin(new DataCenterPlugin());
queryRunner.createDCCatalog("dc", "dc", connectorProperties);
queryRunner.installPlugin(new TpchPlugin());
queryRunner.createCatalog("tpch", "tpch", properties);
return distributedQueryRunner;
return queryRunner;
}
catch (Throwable e) {
closeAllSuppress(e, distributedQueryRunner);
closeAllSuppress(e, queryRunner);
throw e;
}
}

View File

@ -212,31 +212,31 @@ public class TestDataCenterClient
@Test(expectedExceptions = RuntimeException.class)
public void testPasswordWithoutSSL()
{
DataCenterConfig dataCenterConfig = new DataCenterConfig().setConnectionUrl(this.baseUri)
DataCenterConfig config = new DataCenterConfig().setConnectionUrl(this.baseUri)
.setConnectionUser("root")
.setConnectionPassword("root")
.setSsl(false);
DataCenterStatementClientFactory.newHttpClient(dataCenterConfig);
DataCenterStatementClientFactory.newHttpClient(config);
}
@Test(expectedExceptions = RuntimeException.class)
public void testKerberosWithoutSSL()
{
DataCenterConfig dataCenterConfig = new DataCenterConfig().setConnectionUrl(this.baseUri)
DataCenterConfig config = new DataCenterConfig().setConnectionUrl(this.baseUri)
.setConnectionUser("root")
.setKerberosRemoteServiceName("kerberos")
.setSsl(false);
DataCenterStatementClientFactory.newHttpClient(dataCenterConfig);
DataCenterStatementClientFactory.newHttpClient(config);
}
@Test(expectedExceptions = RuntimeException.class)
public void testAccessTokenWithoutSSL()
{
DataCenterConfig dataCenterConfig = new DataCenterConfig().setConnectionUrl(this.baseUri)
DataCenterConfig config = new DataCenterConfig().setConnectionUrl(this.baseUri)
.setConnectionUser("root")
.setAccessToken("token")
.setSsl(false);
DataCenterStatementClientFactory.newHttpClient(dataCenterConfig);
DataCenterStatementClientFactory.newHttpClient(config);
}
@Test(expectedExceptions = RuntimeException.class)

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2021. Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (C) 2018-2020. Huawei Technologies Co., Ltd. All rights reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2021. Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (C) 2018-2020. Huawei Technologies Co., Ltd. All rights reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at

View File

@ -1,6 +1,6 @@
# Audit Log
openLooKeng audit logging functionality is a custom event listener, which monitors the start and stop of openLooKeng cluster and the dynamic addition and deletion of nodes in the cluster; Listen to WebUi user login and exit events; Listen for query events and call when the query is created and completed (success or failure).
openLooKeng audit logging functionality is a custom event listener that is invoked for query creation and query completion (success or failure)
An audit log contains the following information:
1. time when an event occurs
@ -24,17 +24,15 @@ To enable audit logging feature, the following configs must be present in `etc/e
hetu.event.listener.type=AUDIT
hetu.event.listener.listen.query.creation=true
hetu.event.listener.listen.query.completion=true
hetu.auditlog.logoutput=/var/log/
hetu.auditlog.logconversionpattern=yyyy-MM-dd.HH
```
The following is a detailed description of audit logging properties:
Other audit logging properties include:
`hetu.event.listener.type`: property to define logging type for audit files. Allowed values are AUDIT and LOGGER.
`hetu.event.listener.audit.file`: Optional property to define absolute file path for the audit file. Ensure the process running the openLooKeng server has write access to this directory.
`hetu.auditlog.logoutput`: property to define absolute file directory for audit files. Ensure the process running the openLooKeng server has write access to this directory.
`hetu.event.listener.audit.filecount`: Optional property to define the number of files to use
`hetu.auditlog.logconversionpattern`: property to define the conversion pattern of audit files. Allowed values are yyyy-MM-dd.HH and yyyy-MM-dd.
`hetu.event.listener.audit.limit`: Optional property to define the maximum number of bytes to write to any one file
Example configuration file:
@ -43,6 +41,7 @@ event-listener.name=hetu-listener
hetu.event.listener.type=AUDIT
hetu.event.listener.listen.query.creation=true
hetu.event.listener.listen.query.completion=true
hetu.auditlog.logoutput=/var/log/
hetu.auditlog.logconversionpattern=yyyy-MM-dd.HH
hetu.event.listener.audit.file=/var/log/hetu/hetu-audit.log
hetu.event.listener.audit.filecount=1
hetu.event.listener.audit.limit=100000
```

View File

@ -1,25 +0,0 @@
#Extension Physical Execution Planner
This section describes how to add an extension physical execution planner in openLooKeng. With the extension physical execution planner, openLooKeng can utilize other operator acceleration libraries to speed up the execution of SQL statements.
##Configuration
To enable extension physical execution feature, the following configs must be added in
`config.properties`
``` properties
extension_execution_planner_enabled=true
extension_execution_planner_jar_path=file:///xxPath/omni-openLooKeng-adapter-1.6.1-SNAPSHOT.jar
extension_execution_planner_class_path=nova.hetu.olk.OmniLocalExecutionPlanner
```
The above attributes are described below:
- `extension_execution_planner_enabled`: Enable extension physical execution feature.
- `extension_execution_planner_jar_path`: Set the file path of the extension physical execution jar package.
- `extension_execution_planner_class_path`: Set the package path of extension physical execution generated class in jar。
##Usage
The below command can control the enablement of extension physical execution feature in WebUI or Cli while running openLooKeng:
```
set session extension_execution_planner_enabled=true/false
```

View File

@ -16,7 +16,6 @@ hetu.metastore.type=jdbc
hetu.metastore.db.url=jdbc:mysql://....
hetu.metastore.db.user=root
hetu.metastore.db.password=123456
hetu.metastore.cache.type=local
```
The above properties are described below:
@ -25,7 +24,6 @@ The above properties are described below:
- `hetu.metastore.db.url`URL of RDBMS to connect to.
- `hetu.metastore.db.user` :User name of RDBMS to connect to.
- `hetu.metastore.db.password` :Password of RDBMS to connect to.
- `hetu.metastore.cache.type` : Select the cache model, where local is the local cache and global is the distributed cache.
### HDFS Storage

View File

@ -118,20 +118,6 @@ This section describes the most important config properties that may be used to
>
> This is the amount of memory set aside as headroom/buffer in the JVM heap for allocations that are not tracked by openLooKeng.
### `query.suspend-query-enabled`
> - **Type:** `boolean`
> - **Default value:** `false`
>
> Enables running query temporary suspension when system is in low resource situation.
### `query.max-suspended-queries`
> - **Type:** `integer`
> - **Default value:** `10`
>
> Maximum number of queries to attempt suspension before starting of killing the queries. This property comes in effect only if `query.suspend-query-enabled` is configured `true`
## Spilling Properties
### `experimental.spill-enabled`
@ -175,30 +161,6 @@ This section describes the most important config properties that may be used to
>
> This config property can be overridden by the `spill_window_operator` session property.
### `experimental.spill-build-for-outer-join-enabled`
> - **Type:** `boolean`
> - **Default value:** `false`
>
> Enables spill feature for right-outer and full-outer join operations.
>
>
>
> This config property can be overridden by the `spill_build_for_outer_join_enabled` session property.
### `experimental.inner-join-spill-filter-enabled`
> - **Type:** `boolean`
> - **Default value:** `false`
>
> Enables bloom filter based build-side spill matching for probe side spill decision.
>
>
>
> This config property can be overridden by the `inner_join_spill_filter_enabled` session property.
### `experimental.spill-reuse-tablescan`
> - **Type:** `boolean`
@ -217,7 +179,7 @@ This section describes the most important config properties that may be used to
>
> Directory where spilled content will be written. It can be a comma separated list to spill simultaneously to multiple directories, which helps to utilize multiple drives installed in the system.
>
> When `experimental.spiller-spill-to-hdfs` is to `true`, `experimental.spiller-spill-path` must contain only a single directory.
>
>
> It is not recommended to spill to system drives. Most importantly, do not spill to the drive on which the JVM logs are written, as disk overutilization might cause JVM to pause for lengthy periods, causing queries to fail.
@ -278,71 +240,6 @@ This section describes the most important config properties that may be used to
>
> Enables using a randomly generated secret key (per spill file) to encrypt and decrypt data spilled to disk
### `experimental.spill-direct-serde-enabled`
> - **Type:** `boolean`
> - **Default value:** `false`
>
> Enables to serialize/read the page directly to/from the stream.
### `experimental.spill-prefetch-read-pages`
> - **Type:** `integer`
> - **Default value:** `1`
>
> Sets number of pages prefetched while reading from spilled files.
### `experimental.spill-use-kryo-serialization`
> - **Type:** `boolean`
> - **Default value:** `false`
>
> Enables Kryo based serialization for spill to disk, instead of default java serializer.
### `experimental.revocable-memory-selection-threshold`
> - **Type:** `data size`
> - **Default value:** `512 MB`
>
> Sets memory selection threshold for revocable memory of operator to directly allocate revocable memory for remaining bytes ready to revoke.
### `experimental.prioritize-larger-spilts-memory-revoke`
> - **Type:** `boolean`
> - **Default value:** `true`
>
> Enables to prioritize splits with larger revocable memory.
### `experimental.spill-non-blocking-orderby`
> - **Type:** `boolean`
> - **Default value:** `false`
>
> Enables order by operator to use asynchronous mechanism to spill, i.e it can accumulate input even when a spill is in progress and initiate a secondary spill when the secondary data accumulate exceeds a threshold or when the primary spill is completed, the default value of the threshold is the minimum between 20MB and 5% of available free memory. This property must be used in conjunction with the `experimental.spill-enabled` property.
>
>
>
> This config property can be overridden by the `spill_non_blocking_orderby` session property.
### `experimental.spiller-spill-to-hdfs`
> - **Type:** `boolean`
> - **Default value:** `false`
>
> Enables spilling into HDFS. When this property is set to `true` the property `experimental.spiller-spill-profile` must be set and also `experimental.spiller-spill-path` must contain only a single path.
### `experimental.spiller-spill-profile`
> - **Type:** `string`
> - **No default value.** Must be set when spilling to hdfs is enabled
>
>
> This property defines the [filesystem](../develop/filesystem.md) profile used to spill. The corresponding profile must exist in `etc/filesystem`. For example, if this property is set as `experimental.spiller-spill-profile=spill-hdfs`, a profile describing this filesystem `spill-hdfs.properties` must be created in `etc/filesystem` with necessary information including authentication type, config, and keytabs (if applicable, refer [filesystem](../develop/filesystem.md) for details).
>
> This property is required when `experimental.spiller-spill-to-hdfs` is set to `true`. It must be included in configuration files for all coordinators and all workers. The specified file system must be accessible by all workers, and they must be able to read from and write to the path declared in `experimental.spiller-spill-path` folder in the specified file system.
## Exchange Properties
Exchanges transfer data between openLooKeng nodes for different stages of a query. Adjusting these properties may help to resolve inter-node communication issues or improve network utilization.
@ -378,8 +275,19 @@ Exchanges transfer data between openLooKeng nodes for different stages of a quer
>
> Maximum size of a response returned from an exchange request. The response will be placed in the exchange client buffer which is shared across all concurrent requests for the exchange.
>
>
>
> Increasing the value may improve network throughput if there is high latency. Decreasing the value may improve query performance for large clusters as it reduces skew due to the exchange client buffer holding responses for more tasks (rather than hold more data from fewer tasks).
### `exchange.max-error-duration`
> - **Type:** `duration`
> - **Minimum value:** `1m`
> - **Default value:** `7m`
>
> The maximum amount of time coordinator waits for inter-task related errors to be resolved before it's considered a failure.
### `sink.max-buffer-size`
> - **Type:** `data size`
@ -387,113 +295,6 @@ Exchanges transfer data between openLooKeng nodes for different stages of a quer
>
> Output buffer size for task data that is waiting to be pulled by upstream tasks. If the task output is hash partitioned, then the buffer will be shared across all of the partitioned consumers. Increasing this value may improve network throughput for data transferred between stages if the network has high latency or if there are many nodes in the cluster.
## Failure Recovery handling Properties
### Failure Retry Policies
### `failure.recovery.retry.profile`
> - **Type:** `String`
> - **Default value:** `default`
>
> This property defines the failure detection profile used to determine if failure has happened for a http client. The value `<profile-name>` set for this property has to correspond to `<profile-name>.properties` file in `etc/failure-retry-policy/`. In case no such profile is available, and this property is not set, "default" profile is used.
> For example, `failure.recovery.retry.profile="test"` requires `test.properties` file to be present in `etc/failure-retry-policy`.
> The file `test.properties` must contain `failure.recovery.retry.type` specified.
### `failure.recovery.retry.type`
> - **Type:** `String`
> - **Default value:** `timeout`
>
> The failure detection mechanism in use. Default is timeout based failure detection.
>
#### `timeout` based failure detection.
> Using this mechanism, HTTP client failures are retried for a specific duration before considering it as a permanent failure.
> Additional properties `max.error.duration` can be defined for this type of failure detection.
>
#### `max-retry` based failure detection.
> Using this mechanism, HTTP client failures are retried for a specific number of times before considering it as a permanent failure.
> Additional properties `max.retry.count` and `max.error.duration` can be defined for this type of failure detection.
> Using this type of failure detection is configured to be used, `max.retry.count` times retry is performed before consulting the failure detector module. When the remote node is failed as per the failure detector module, HTTP client considers it a permanent failure. Otherwise, i.e. When remote worker node is alive but not sending response, retry happens for `max.error.duration` before considering it as permanent failure.
### `max.error.duration`
> - **Type:** `duration`
> - **Default value:** `300s`
>
> The maximum amount of time coordinator waits for inter-task related errors to be resolved before it's considered a permanent failure.
### `max.retry.count`
> - **Type:** `integer`
> - **Default value:** `100`
>
> The maximum number of retry for failed task performed by the coordinator before consulting the failure detector module about the remote node status.
> This parameter is the minimum count before consulting the failure detection module. Hence, the actual number of failures may vary slightly based on the cluster size, and load on the cluster.
> This property is used only for `max-retry` based failure detection profiles.
> The minimum value for this parameter is 100.
### Gossip Protocol Configurations for Failure Detection
### `failure-detection-protocol`
>- **Type:** String
>- **Default value:** `heartbeat`
>
> This property defines the type of failure detector in use. Default configuration is `heartbeat` failure detector.
> Gossip protocol can be enabled by specifying this parameter in `config.properties` file, with the value `gossip`.
> All nodes (i.e. coordinator as well as workers) in a cluster should have this property specified in their respective `etc/config.properties` file.
### `failure-detector.heartbeat-interval`
>- **Type:** Duration
>- **Default value:** `500ms` (500 miliseconds)
>
> This is the interval of gossip between two nodes in the cluster.
> In gossip protocol, two workers are expected to gossip with higher frequency than the coordinator and a worker.
> In `config.properties` for the coordinator, this property can be set with a reasonably higher value, such as `5s` (5 seconds).
> In workers, this property can be left to use the default value.
>
### `failure-detector.worker-gossip-probe-interval`
>
> - **Type:** Duration
>- **Default value:** `5s` (5 seconds)
>
> Gossip protocol uses monitoring tasks (same as the heartbeat failure detector) to keep tab on the other nodes.
> This property specifies the interval of refreshing the monitoring tasks to trigger worker to worker gossip.
> This property, if needed to be configured with any other value than the default, should be specified only for the worker nodes.
> This parameter should have higher value than `failure-detector.heartbeat-interval`.
>
### `failure-detector.coordinator-gossip-probe-interval`
>
> - **Type:** Duration
>- **Default value:** `5s` (5 seconds)
>
> Gossip protocol uses monitoring tasks (same as the heartbeat failure detector) to keep tab on the other nodes.
> This property specifies the interval of refreshing the monitoring tasks to trigger coordinator to worker gossip.
> This property, if needed to be configured with any other value than the default, should be specified only for the coordinator.
> This parameter should have higher value than `failure-detector.heartbeat-interval` and `failure-detector.worker-gossip-probe-interval`.
>
### `failure-detector.coordinator-gossip-collate-interval`
>
> - **Type:** Duration
>- **Default value:** `2s` (2 seconds)
>
> This property specifies the interval in which the coordinator collates all the gossips it obtained from all the workers.
> This property has to be specified only for the coordinator.
> This parameter should have higher value than `failure-detector.heartbeat-interval`.
>
### `failure-detector.gossip-group-size`
>
> - **Type:** Integer
>- **Default value:** `Integer.MAX_VALUE`
>
> A worker should gossip with how many other workers in the cluster, is defined by this parameter.
> Any value higher than the cluster-size (i.e. the number of workers) implies all-to-all gossip.
> To keep the network overhead low, this value should be reasonably low for a big cluster (e.g. 10 for a cluster size of 100).
> On each refresh of the worker-monitoring tasks at the coordinator, the coordinator defines the list of worker URIs of size `failure-detector.gossip-group-size` to trigger worker-to-worker gossip.
## Task Properties
### `task.concurrency`
@ -878,7 +679,7 @@ helps with cache affinity scheduling.
> Auto-Vacuum enables the system to automatically manage vacuum jobs by constantly monitoring the tables which needs vacuum in order to maintain optimal performance.
> Engine gets the tables from data sources that are eligible for vacuum and trigger vacuum operation for those tables.
### `auto-vacuum.enabled`
### `auto-vacuum.enabled:`
> - **Type:** `boolean`
> - **Default value:** `false`
@ -948,25 +749,15 @@ helps with cache affinity scheduling.
> - **Default value:** `5m`
>
> The maximum time coordinator waits for remote-task related error to be resolved before it's considered a failure.
>
> Note:
> For snapshot recovery `query.remote-task.max-error-duration` should be greater than `exchange.max-error-duration`.
## Query Recovery
### `recovery_enabled`
> - **Type:** `boolean`
> - **Default value:** `false`
>
> This session property is used to enable or disable the recovery framework, which enables to restart/resume the query in case of failure.
## Distributed Snapshot
### `snapshot_enabled`
> - **Type:** `boolean`
> - **Default value:** `false`
>
> This session property is enabled to capture snapshots during query execution, when recovery framework is enabled. Without recovery framework enabled this flag has no significance
> This session property is used to enable or disable the distributed snapshot functionality.
### `hetu.experimental.snapshot.profile`
@ -978,67 +769,20 @@ helps with cache affinity scheduling.
>
> This is an experimental property. In the future it may be allowed to store snapshots in non-file-system locations, e.g. in a connector.
### `hetu.recovery.maxRetries`
### `hetu.snapshot.maxRetries`
> - **Type:** `int`
> - **Default value:** `10`
>
> This property defines the maximum number of error recovery attempts for a query. When the limit is reached, the query fails.
>
> This can also be specified on a per-query basis using the `recovery_max_retries` session property.
> This can also be specified on a per-query basis using the `snapshot_max_retries` session property.
### `hetu.recovery.retryTimeout`
### `hetu.snapshot.retryTimeout`
> - **Type:** `duration`
> - **Default value:** `10m` (10 minutes)
>
> This property defines the maximum amount of time for the system to wait until all tasks are successfully restored. If any task is not ready within this timeout, then the recovery attempt is considered a failure, and the query will try to resume from an earlier snapshot if available.
>
> This can also be specified on a per-query basis using the `recovery_retry_timeout` session property.
### `hetu.snapshot.useKryoSerialization`
> - **Type:** `boolean`
> - **Default value:** `false`
>
> Enables Kryo based serialization for snapshot, instead of default java serializer.
### `experimental.eliminate-duplicate-spill-files`
> - **Type:** `boolean`
> - **Default value:** `false`
>
> Enables elimination of duplicate spill files storage as part of snapshot capture.
## HTTP Client Configurations
### `http.client.idle-timeout`
> - **Type:** `duration`
> - **Default value:** `30s` (30 seconds)
>
> This property defines the time for which a given http client shall stay connected without any operations performed over it.
> After the specified time elapse with no activity, then the client connection is closed and related resources are released.
>
> (Note: this parameter should be configured with higher time when in high load environment)
### `http.client.request-timeout`
> - **Type:** `duration`
> - **Default value:** `10s` (10 seconds)
>
> This property defines the time threshold for a given http client for which response should be received.
> After the configured time elapsed and no response received, then client connection consider that to be failure in submission of request.
>
> (Note: this parameter should be configured with higher time when in high load environment)
## Connector Properties configuration
### `case-insensitive-name-matching`
>
> - **Type:** `boolean`
> - **Default value:** `false`
>
> Case-insensitive matching between database and collection names. The default is case sensitive.
> This can also be specified on a per-query basis using the `snapshot_retry_timeout` session property.

View File

@ -11,15 +11,14 @@ To achieve better performance while maintaining execution reliability, the *dist
As of release 1.2.0, openLooKeng supports recovery of tasks and worker node failures.
## Enable Recovery framework
## Enable Distributed Snapshot
Recovery framework is most useful for long running queries. It is disabled by default, and must be enabled and disabled via a session property [`recovery_enabled`](properties.md#recovery_enabled). It is recommended that the feature is only enabled for complex queries that require high reliability.
Distributed snapshot is most useful for long running queries. It is disabled by default, and must be enabled and disabled via a session property [`snapshot_enabled`](properties.md#snapshot_enabled). It is recommended that the feature is only enabled for complex queries that require high reliability.
## Requirements
To be able to resume execution from a previously saved snapshot, there must be a sufficient number of workers available so that all previous tasks can be restored. To enable distributed snapshot for a query, the following is required:
- at least 2 workers
- at least 50% more available cluster-wide memory resources with tolerance for worker node failure. If constrained by memory, not all queries may be able to recover (see [I44RMW](https://e.gitee.com/open_lookeng/issues/list?issue=I44RMW))
- at least 80% (rounded down) of previously available workers still active for the resume to be successful. If not enough workers are available, the query will not be able to
resume from any previous snapshot, so the query reruns from the beginning.
@ -37,7 +36,7 @@ When a query that does not meet the above requirements is submitted with distrib
## Detection
Error recovery is triggered when communication between the coordinator and a remote task fails for an extended period of time, as controlled by the [`Failure Recovery handling Properties`](properties.md#Failure Recovery handling Properties) configuration.
Error recovery is triggered when communication between the coordinator and a remote task fails for an extended period of time, as controlled by the [`query.remote-task.max-error-duration`](properties.md#queryremote-taskmax-error-duration) configuration.
## Storage Considerations
@ -47,7 +46,7 @@ Snapshot data is stored in a file system as specified using the `hetu.experiment
Snapshot files are stored under `/tmp/hetu/snapshot/` folder of the file system. All workers must be authorized to read and write to this folder.
Snapshots reflect states in query execution, potentially becoming very large in size and varying significantly from query to query. For example, queries that need to buffer large amounts of data (typically involving ordering, window, join, aggregation, etc. operations), may result in snapshots that include data from an entire table. Ensure that the cluster has enough memory to process the snapshots and the shared file system has sufficient disk space available to store these snapshots before proceeding.
Snapshots reflect states in query execution, potentially becoming very large in size and varying significantly from query to query. For example, queries that need to buffer large amounts of data (typically involving ordering, window, join, aggregation, etc. operations), may result in snapshots that include data from an entire table. Ensure that the shared file system has sufficient space available to save these snapshots before proceeding.
Each query execution may produce multiple snapshots. Contents of these snapshots may overlap. Currently they are stored as separate files. In the future, "incremental snapshots" feature may be introduced to save storage space.
@ -55,20 +54,8 @@ Each query execution may produce multiple snapshots. Contents of these snapshots
The ability to recover from an error and resume from a snapshot does not come for free. Capturing a snapshot, depending on complexity, takes time. Thus it is a trade-off between performance and reliability.
It is suggested to turn on snapshot capture when necessary, i.e. for queries that run for a long time. For these types of workloads, the overhead of taking snapshots becomes negligible.
## Snapshot statistics
Snapshot capture and restore statistics are displayed in CLI along with query result when CLI is launched in debug mode
Snapshot capture statistics includes number of snapshots captured, size of snapshots captured, CPU Time taken for capturing the snapshots and Wall Time taken for capturing the snapshots during the query. These statistics are displayed for all snapshots and for last snapshot separately.
Snapshot restore statistics covers number of times restored from snapshots during query, Size of the snapshots loaded for restoring, CPU Time taken for restoring from snapshots and Wall Time taken for restoring from snapshots. Restore statistics are displayed only when there is restore(recovery) happened during the query.
Additionally, while query is in progress number of capturing snapshots and id of the restoring snapshot will be displayed. Refer below picture for more details
![](../images/snapshot_statistics.png)
It is suggested to only turn on distributed snapshot when necessary, i.e. for queries that run for a long time. For these types of workloads, the overhead of taking snapshots becomes negligible.
## Configurations
Configurations related to recovery framework feature can be found in [Properties Reference](properties.md#Query Recovery).
Configurations related to distributed snapshot feature can be found in [Properties Reference](properties.md#distributed-snapshot).

View File

@ -12,7 +12,7 @@ Properties related to spilling are described in `tuning-spilling`.
## Memory Management and Spill
By default, openLooKeng kills queries if the memory requested by the query execution exceeds session properties `query_max_memory` or `query_max_memory_per_node`. This mechanism ensures fairness in allocation of memory to queries and prevents deadlock caused by memory allocation. It is efficient when there are lots of small queries in the cluster, but leads to killing large queries that don\'t stay within the limits.
By default, openLooKeng kills queries if the memory requested by the query execution exceeds session properties `query_max_memory` or `query_max_memory_per_node`. This mechanism ensures fairness in allocation of memory to queries and prevents deadlock caused by memory allocation. It is efficient when there is a lot of small queries in the cluster, but leads to killing large queries that don\'t stay within the limits.
To overcome this inefficiency, the concept of revocable memory was introduced. A query can request memory that does not count toward the limits, but this memory can be revoked by the memory manager at any time. When memory is revoked, the query runner spills intermediate data from memory to disk and continues to process it later.
@ -34,10 +34,6 @@ saturation of the configured spill paths.
openLooKeng treats spill paths as independent disks (see [JBOD](https://en.wikipedia.org/wiki/Non-RAID_drive_architectures#JBOD)), so there is no need to use RAID for spill.
## Spill To HDFS
Spilling directly into HDFS is also possible for that `experimental.spiller-spill-to-hdfs` needs to be set to `true`, `experimental.spiller-spill-profile` needs to be set and `spiller-spill-path` must contain only a single directory when we intend to spill into HDFS. (refer `experimental.spiller-spill-to-hdfs` and `experimental.spiller-spill-profile` properties for more details )
## Spill Compression
@ -65,21 +61,18 @@ When the build table is partitioned, the spill-to-disk mechanism can decrease th
With this mechanism, the peak memory used by the join operator can be decreased to the size of the largest build table partition. Assuming no data skew, this will be `1 / task.concurrency` times the size of the whole build table.
Note: spill-to-disk is not supported for Cross Join.
### Aggregations
Aggregation functions perform an operation on a group of values and return one value. If the number of groups you\'re aggregating over is large, a significant amount of memory may be needed. When spill-to-disk
is enabled, if there is not enough memory, intermediate accumulated aggregation results are written to disk. They are loaded back and merged with a lower memory footprint.
is enabled, if there is not enough memory, intermediate cumulated aggregation results are written to disk. They are loaded back and merged with a lower memory footprint.
### Order By
If you're trying to sort a larger amount of data, a significant amount of memory may be needed. When spill to disk for order by is enabled, if there is not enough memory, intermediate sorted results are written to disk. They are loaded back and merged with a lower memory footprint.
Generally when a spill is in progress the operator is blocked from taking inputs, but when `experimental.spill-non-blocking-orderby` is set to `true` order by uses asynchronous mechanism to spill (see`experimental.spill-non-blocking-orderby`).
If you're trying to sort a larger amount of data, a significant amount of memory may be needed. When spill to disk for order by is enabled, if there is not enough memory, intemediate sorted results are written to disk. They are loaded back and merged with a lower memory footprint.
### Window functions
Window Functions perform an operators over a window of rows and return one value for each row. If this window of rows is large, a significant amount of memory may be needed. When spill to disk for window functions is enabled, if there is not enough memory, intermediate sorted results are written to disk. They are loaded back and merged when memory is available. There is a current limitation that spill will not work in all cases such as when a single window is very large.
Window Functions perform an operators over a window of rows and return one value for each row. If this window of rows is large, a significant amount of memory may be needed. When spill to disk for window functions is enabled, if there is not enough memory, intemediate sorted results are written to disk. They are loaded back and merged when memory is available. There is a current limitation that spill will not work in all cases such as when a single window is very large.
### Reuse Exchange

View File

@ -1,5 +1,5 @@
# State Store
This section describes the openLooKeng state store. State store is used to store states that are shared between state store members and state store clients.
This section describes the openlookeng state store. State store is used to store states that are shared between state store members and state store clients.
State store cluster is composed of state store members, and state store clients can do all state store operations without being a member of cluster.

View File

@ -33,54 +33,4 @@ and statistics about the query is available by clicking the *JSON* link. These v
> - **Allowed values:** `true`, `false`
> - **Default value:** `false`
>
> Insecure authentication over HTTP is disabled by default. This could be overridden via `hetu.queryeditor-ui.allow-insecure-over-http` property of `etc/config.properties` (e.g. hetu.queryeditor-ui.allow-insecure-over-http=true).
### `hetu.queryeditor-ui.execution-timeout`
> - **Type:** `duration`
> - **Default value:** `100 DAYS`
>
> UI Execution timeout is set to 100 days as default. This could be overridden via `hetu.queryeditor-ui.execution-timeout` of `etc/config.properties`
### `hetu.queryeditor-ui.max-result-count`
> - **Type:** `int`
> - **Default value:** `1000`
>
> UI max result count is set to 1000 as default. This could be overridden via `hetu.queryeditor-ui.max-result-count` of `etc/config.properties`
### `hetu.queryeditor-ui.max-result-size-mb`
>- **Type:** `size`
>- **Default value:** `1GB`
>
> UI max result size is set to 1 GB as default. This could be overridden via `hetu.queryeditor-ui.max-result-size-mb` of `etc/config.properties`
### `hetu.queryeditor-ui.session-timeout`
> - **Type:** `duration`
> - **Default value:** `1 DAYS`
>
> UI session timeout is set to 1 day as default. This could be overridden via `hetu.queryeditor-ui.session-timeout` of `etc/config.properties`
### `hetu.queryhistory.max-count`
> - **Type:** `int`
> - **Default value:** `1000`
>
> The maximum number of query history stored by openLooKeng. This could be overridden via "hetu.queryhistory.max-count" of "etc/config.properties".
### `hetu.collectionsql.max-count`
> - **Type:** `int`
> - **Default value:** `100`
>
> The Maximum number of SQL collected by each user. This could be overridden via "hetu.collectionsql.max-count" of "etc/config.properties".
## Remarks
The max length of the favorite SQL is 600 by default. You can modify it through the following steps:
1. Login MySQL database according to the JDBC configuration of `hetu-metastore.properties`
2. Select table hetu_favorite, execute script `alter table hetu_favorite modify query varchar(2000) not null;` to modify the max length of the favorite SQL.
> Insecure authentication over HTTP is disabled by default. This could be overridden via "hetu.queryeditor-ui.allow-insecure-over-http" property of "etc/config.properties" (e.g. hetu.queryeditor-ui.allow-insecure-over-http=true).

View File

@ -1,8 +1,5 @@
# Hudi Connector
### Release Notes
Currently Hudi only supports version 0.7.0.
### Hudi Introduction
Apache Hudi is a fast growing data lake storage system that helps organizations build and manage petabyte-scale data lakes. Hudi enables storing vast amounts of data on top of existing DFS compatible storage while also enabling stream processing in addition to typical batch-processing. This is made possible by providing two new primitives. Specifically,

View File

@ -192,4 +192,4 @@ The array fields of this structure can be defined by using the following command
## Limitations
1. openLooKeng does not support to query table in Elasticsearch which has duplicated columns, such as column "name" and "NAME";
2. openLooKeng does not support to query the table in Elasticsearch that the name has special characters, such as '-', '.', etc.
2. opneLooKeng does not support to query the table in Elasticsearch that the name has special characters, such as '-', '.', etc.

Some files were not shown because too many files have changed in this diff Show More