Skip to content
Snippets Groups Projects
Commit 671799f6 authored by Thomas Blum's avatar Thomas Blum
Browse files

make attribute definition in insert statement optional; support * operator in select statement

parent 83636435
No related branches found
No related tags found
No related merge requests found
Pipeline #38548 failed
......@@ -28,7 +28,7 @@ Value::~Value()
value_op_t Value::castString(const std::string & str, SqlType type)
{
//assert(!type.nullable);
assert(!type.nullable);
switch (type.typeID) {
case SqlType::TypeID::UnknownID:
......@@ -58,7 +58,7 @@ value_op_t Value::load(const void * ptr, SqlType type)
{
if (type.nullable) {
// return NullableValue::load(ptr, type);
// throw NotImplementedException();
throw NotImplementedException();
}
switch (type.typeID) {
......
......@@ -15,6 +15,8 @@ namespace semanticalAnalysis {
std::vector<std::string> definedColumnNames;
std::vector<std::string> typeNames = {"bool","date","integer","longinteger","numeric","char","varchar","timestamp","text"};
for (auto &column : stmt->columns) {
if (column.nullable) throw semantic_sql_error("not supported nullable option for column '" + column.name + "'");
if (std::find(definedColumnNames.begin(),definedColumnNames.end(),column.name) != definedColumnNames.end())
throw semantic_sql_error("column '" + column.name + "' already exists");
definedColumnNames.push_back(column.name);
......
......@@ -15,8 +15,8 @@ namespace semanticalAnalysis {
if (db._branchMapping.find(stmt->relation.version) == db._branchMapping.end()) throw semantic_sql_error("version '" + stmt->relation.version + "' does not exist");
Table *table = db.getTable(stmt->relation.name);
std::vector<std::string> columnNames = table->getColumnNames();
if (stmt->columns.size() != stmt->values.size())
throw semantic_sql_error("required attribute definition for table'" + stmt->relation.name + "'");
if (stmt->columns.size() == 0 && stmt->values.size() != table->getColumnNames().size() )
throw semantic_sql_error("values for columns of table '" + stmt->relation.name + "' must be specified");
for (auto &column : stmt->columns) {
if (std::find(columnNames.begin(),columnNames.end(),column.name) == columnNames.end())
throw semantic_sql_error("column '" + column.name + "' does not exist");
......@@ -40,6 +40,12 @@ namespace semanticalAnalysis {
master_branch_id;
std::vector<std::unique_ptr<Native::Sql::Value>> sqlvalues;
if (stmt->columns.empty()) {
for (auto &column : table->getColumnNames()) {
stmt->columns.push_back(Column());
stmt->columns.back().name = column;
}
}
for (int i=0; i<stmt->columns.size(); i++) {
Native::Sql::SqlType type = table->getCI(stmt->columns[i].name)->type;
std::string &value = stmt->values[i];
......
......@@ -103,6 +103,15 @@ namespace semanticalAnalysis {
projectedIUs.push_back(_context.ius[column.table][column.name]);
}
}
if (stmt->projections.empty()) {
for (auto &relation : stmt->relations) {
std::string &productionName = relation.alias.empty() ? relation.name : relation.alias;
for (auto &iu : _context.ius[productionName]) {
if (iu.second->columnInformation->columnName == "tid") continue;
projectedIUs.push_back(iu.second);
}
}
}
_context.joinedTree = std::make_unique<Result>( std::move(_context.joinedTree), projectedIUs );
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment