org.apache.phoenix.parse.CreateTableStatement Maven / Gradle / Ivy
The newest version!
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.phoenix.parse;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import org.apache.hadoop.hbase.HColumnDescriptor;
import org.apache.hadoop.hbase.util.Pair;
import org.apache.phoenix.jdbc.PhoenixDatabaseMetaData;
import org.apache.phoenix.query.QueryConstants;
import org.apache.phoenix.schema.PTableType;
import org.apache.phoenix.schema.TableProperty;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableListMultimap;
import com.google.common.collect.ListMultimap;
public class CreateTableStatement extends MutableStatement {
private final TableName tableName;
private final PTableType tableType;
private final List columns;
private final PrimaryKeyConstraint pkConstraint;
private final List splitNodes;
private final int bindCount;
private final ListMultimap> props;
private final boolean ifNotExists;
private final TableName baseTableName;
private final ParseNode whereClause;
// TODO change this to boolean at the next major release and remove TableProperty.IMMUTABLE_ROWS and QueryServiceOptions.IMMUTABLE_ROWS_ATTRIB
private final Boolean immutableRows;
public CreateTableStatement(CreateTableStatement createTable, List columns) {
this.tableName = createTable.tableName;
this.tableType = createTable.tableType;
this.columns = ImmutableList.copyOf(columns);
this.pkConstraint = createTable.pkConstraint;
this.splitNodes = createTable.splitNodes;
this.bindCount = createTable.bindCount;
this.props = createTable.props;
this.ifNotExists = createTable.ifNotExists;
this.baseTableName = createTable.baseTableName;
this.whereClause = createTable.whereClause;
this.immutableRows = createTable.immutableRows;
}
protected CreateTableStatement(TableName tableName, ListMultimap> props, List columns, PrimaryKeyConstraint pkConstraint,
List splitNodes, PTableType tableType, boolean ifNotExists,
TableName baseTableName, ParseNode whereClause, int bindCount, Boolean immutableRows) {
this.tableName = tableName;
this.props = props == null ? ImmutableListMultimap.>of() : props;
this.tableType = PhoenixDatabaseMetaData.SYSTEM_CATALOG_SCHEMA.equals(tableName.getSchemaName()) ? PTableType.SYSTEM : tableType;
this.columns = columns == null ? ImmutableList.of() : ImmutableList.copyOf(columns);
this.pkConstraint = pkConstraint == null ? PrimaryKeyConstraint.EMPTY : pkConstraint;
this.splitNodes = splitNodes == null ? Collections.emptyList() : ImmutableList.copyOf(splitNodes);
this.bindCount = bindCount;
this.ifNotExists = ifNotExists;
this.baseTableName = baseTableName;
this.whereClause = whereClause;
this.immutableRows = immutableRows;
}
public ParseNode getWhereClause() {
return whereClause;
}
@Override
public int getBindCount() {
return bindCount;
}
public TableName getTableName() {
return tableName;
}
public TableName getBaseTableName() {
return baseTableName;
}
public List getColumnDefs() {
return columns;
}
public List getSplitNodes() {
return splitNodes;
}
public PTableType getTableType() {
return tableType;
}
public ListMultimap> getProps() {
return props;
}
public boolean ifNotExists() {
return ifNotExists;
}
public PrimaryKeyConstraint getPrimaryKeyConstraint() {
return pkConstraint;
}
public Boolean immutableRows() {
return immutableRows;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy