血缘解析
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

63 lines
2.1 KiB

package com.guozhi.bloodanalysis.parser.common;
import java.util.List;
import com.guozhi.bloodanalysis.parser.vo.KColumn;
import com.guozhi.bloodanalysis.parser.vo.VTable;
import gudusoft.gsqlparser.nodes.TAlterTableOptionList;
import gudusoft.gsqlparser.nodes.TObjectName;
import gudusoft.gsqlparser.stmt.TAlterTableStatement;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;
/**
* Created by Walk.Lai on 2015/8/29.
*/
public class AlterParser {
private TAlterTableStatement mStmt;//table, view
private List<KColumn> mColumns;
private VTable mTable;
private ParserContext mParserContext;
public AlterParser(TAlterTableStatement alterSql,ParserContext context){
mStmt =alterSql;
this.mParserContext=context;
}
public void parse() {
//alter table exchange partition with table
// --将新数据以交换分区方式插入目标表
// ALTER TABLE IML_DB.EV_EVENT_PROD_RELA EXCHANGE SUBPARTITION P_1008_1111 WITH TABLE IML_DB.VT_NEW_1008;
/*
例如 ALTER TABLE $PDM_SCH.PD_BCC_3F_TRAN_INFO RENAME TO PD_BCC_3F_TRAN_INFO_EXCHANGE2;
ALTER TABLE $PDM_SCH.PD_BCC_3F_TRAN_INFO_EXCHANGE RENAME TO PD_BCC_3F_TRAN_INFO;
tempTable -- $PDM_SCH.PD_BCC_3F_TRAN_INFO_EXCHANGE
targetTable -- PD_BCC_3F_TRAN_INFO
*/
String tempTableName = null;
String targetTableName = null;
TObjectName obj = mStmt.getTableName();
if (obj!=null) {
tempTableName = obj.toString();
}
TAlterTableOptionList oplist = mStmt.getAlterTableOptionList();
if (oplist!=null) {
for (int i = 0; i < oplist.size(); i++) {
String option = oplist.getAlterTableOption(i).toString();
if (option.contains("RENAME")&&option.contains(" TO ")) {
targetTableName = option.substring(option.indexOf(" TO ")+" TO ".length()).trim();
targetTableName = targetTableName.replace("SYMBOLALTERPOINT", ".");
// targetTableName = this.addAlterSchema(tempTableName,targetTableName);
break;
}
}
}
}
public List<KColumn> getParseResult() {
return null;
}
}