я отправляю тебе задание, скажи, какую последнюю строчку ты получишь.
Общее описание задачи на C++

от вас требуется реализовать собственную in-memory реляционную базу данных.
Чтобы не беспокоиться о сетевых взаимодействиях, правах доступа, пользовательском интерфейсе и прочих подобных вещах, оформить ее предлагается в виде библиотеки, которую можно подключить к произвольному проекту и использовать либо напрямую из пользовательского кода, либо через сторонние интерфейсы (по сети, из консоли или как-нибудь еще).
Что представляет из себя база данных? На самом деле, просто набор таблиц, состоящих из именованных колонок (как правило, их число фиксировано, либо меняется очень редко) и произвольного количества строк (вот они могут добавляться и удаляться часто). Можно думать об этом, как о множестве неких структур.
Естественно, просто хранить таблицы недостатчоно, требуется так же выполнять запросы к ним. Запросы как правило заключаются в добавлении /удалении строк, изменениии существующих и выборке по произвольным условиям. Естественно, критична производительность всего этого.
Требуются следующие возможности:
1. Создание объекта базы. Независимых объектов может быть много и с точки зрения пользователя они ничего не знают друг о друге.
2. Выполнение запросов (иначе какая это база данных). Поскольку предполагается, что запросы могут поступать динамически, требуется единый интерфейс, принимающий их в текстовом виде. Условный db.execute(user_query). О языке запросов - в секции 3.
3. Получение результатов запросов. Если точнее, хочется иметь возможность проитерироваться по строкам результата и получить из них значения конкретных колонок по их именам.
4. Сохранение состояний базы в файл и последующая его загрузка.
5. Естественно, критичны скорость работы и потребление памяти.

Ожидаемый интерфейс выглядит примерно так (но вы можете придумать лучше):
```
memdb::Database db;
db.load_from_file(std::ifstream("db.bin", ios::bin));
auto result = db.execute(query);
if (result.is_ok()) {
for (auto &row : result) {
int i = resp.get<int>("column1");
std::string_view s = resp.get<std::string_view>("column2");
do_something(i, s);
}
} else {
std::cerr << "Error: " << result.get_error() << "\n";
}
...
db.save_to_file(std::ofstream("db.bin", ios::bin));
```

Способ сдачи и требования к решению

Проверка проходит вручную. На проверку вы сдаете код с описанием его работы и инструкцией по компиляции и использованию. 
Запрещено использование библиотек, которые уже реализуют требуемую функциональность или ее часть (например LLVM или sqlite).
Служебные библиотеки (например ranges) или библиотеки для тестирования (boost::ut, gtest) — разрешены.
К реализации должны быть написаны тесты.
Проверяющий в праве задать любые уточняющие вопросы.
Не забывайте про хорошую декомпозицию кода.

Язык запросов

Можно было бы реализовать полноценный SQL, но мы возьмем собственный язык, похожий на него. Это во-первых, позволит проигнорировать несущественные вещи из SQL, а во-вторых даст возможность для расширений языка.

Общие правила:

- Ключевые слова (select, create и т.п.) - нечувствительны к регистру.
- Названия пользовательских сущностей (таблиц и колонок) — чувствительны.
- Требования к названиям — такие же, как в С++. Для простоты считаем, что все символы — ASCI.
- Пробельные символы (включая перевод строки) служат для разделения ключевых слов или параметров. Разделитель может содержать произвольное их количество (но, конечно, больше нуля).

Типы данных

Для простоты введем всего 4 типа данных:

1. int32 — знаковое 32-битное целое число. В запросах записывается, как последовательность цифр, возможно начинающаяся со знака + или -.
2. bool — логическое значение (true или false). В запросах записывается одноименными ключевыми словами.
3. string[X] - строка длины не больше X. В запросах записывается внутри двойных ковычек ("). Может содержать экранированные символы, аналогично строковым литералам в С++ (например "\x00\n\t").
4. bytes[X] - байтовая последовательность длины ровно X. В запросах описывается либо аналогично строке, либо в шестнадцатиричном виде: 0x000abeef

Выражения

Чтобы делать любые хоть немного сложные запросы надо уметь выполнять операции с данными. Мы ограничимся следующими:

- Арифметика (+, -, *, /, %) - выполняется над числами, семантика аналогична С++.
- Сравнения (<, =, >, <=, >=, !=) - выполняется над двумя значениями одинакового типа, семантика аналогична С++, кроме операции =, которая аналогична ==. Числа сравниваются очевидным образом, строки и байтовые последовательности - лексикографически, логические значения - по правилу true > false.
- Логические операции &&, ||, !, ^^ - применяются к логическим значениям, аналогичны С++, кроме ^^, который аналогичен ^
- |s| — применяется к строкам и байтовым последовательностям означет длину строки/последовательности.
- + для строк — конкатенация
- Скобки — задают приоритет операций
Приоритеты операций аналогичны таковым в С++. Неявных преобразваний типов нет, т.е. 42 || 0 или true + false - считаются невалидными выражениями.

Create table

Основная сущность базы данных - это таблица. Но чтобы с ней работать, надо ее сначала создать: create table <имя таблицы> (описание
колонок)
Описание колонок - это последовательность разделенных запятой описаний следующего вида: [{attributes}] <name>: <type> [= <value>],
где
- name - имя колонки
- type - тип значений в колонке
- value - значение по-умалчанию для содержимого колонки, если оно есть
- attributes - последовательность аттрибутов колонки, перечисленных через запятую. Аттрибуты служат для более точного описания свойств колонки. Нужно реализовать хотя бы 3 аттрибута:
+ unique - означает, что значения в колонке должны быть уникальными
+ autoincrement - означет, что при добавлении новых строк значение в этой колонке в первый раз будет 0 и будет становиться на 1 больше в каждой новой строке. Применимо только к целочисленным колонкам.
+ key - то же, что unique, но автоматически построит индекс (о них ниже) по каждой колонке с этим аттрибутом.
Пример запроса: create table users ({key, autoincrement} id : int32, {unique} login: string[32], password_hash: bytes [8], is_admin: bool = false)

Insert

Служит для добавления новых строк в таблицу.
Синтаксис: insert (<values>) to <table>, где
- table - имя таблицы, куда надо вставить значения.
- values - одно из двух. Либо просто список значений через запятую, либо последовательность записей вида <name> = <value>, разделенных запятыми, где name - имя колонки в таблице, a value значение. В случае использования второго вида порядок колонок не важен. Колонки, которые имеют значение по умолчанию или атрибут autoincrement - можно опустить. В первой форме записи для этого просто оставляют пустое место между запятыми (см. примеры).
Примеры:
- insert (,"vasya", Oxdeadbeefdeadbeef) to users
- insert (login = "vasya", password_hash = Oxdeadbeefdeadbeef) to users (эквивалентно предыдущему)
- insert (, "admin", 0x0000000000000000, true) to users
- insert (
    is_admin = true,
    login = "admin",
    password_hash = 0x0000000000000000
) to users (эквивалентно предыдущему)

Select

Запрос выборки данных. Берет таблицу, выбирает из нее данные, соответствующие условия и возвращает новую таблицу.
Синтаксис: select <columns> from <table> where <condition>, где
- table - либо имя таблицы, из которой надо получить значения, либо выражение join (о них ниже)
- columns имена колонок через запятую в формате <table>.<column> (например users.id). Если в запросе используется только одна таблица то ее имя можно опустить и писать только имя колонки.
- condition - логическое выражение над значениями колонок, по которому надо отфильтровать результаты.
Пример: select id, login from users where is_admin || id < 10

Update
Запрос обновления данных.
Синтаксис: update <table> set <assignments> where <condition>,
где
- table - аналогично select
- condition аналогично select
- assignments набор имен колонок и их значений, синтаксис анналогичен второй форме insert за исключением того, что значения могут быть не константами, а выражениями от старых значений данной строки.
Примеры:
- update users set is_admin = true where login = "vasya"
- update users set login = login + "_deleted", is_admin = false where password_hash < 0x00000000ffffffff

Delete
Запрос удаления данных.
Синтаксис: delete <table> where <condition>, где
- table - имя таблицы, из которой надо удалить строки
- condition - аналогично select
Пример:
delete users where |login| % 2 = 0

Join
Естественно, делать запросы к отдельным таблицам - не особо полезно.
Чтобы собирать данные из нескольких таблиц служит join.
Это не отдельная команда, а конструкция, которая может использоваться в запроcax select и update вместо имени таблицы.
join делает очень простую вещь - он выбирает из первой и второй таблицы пары строк, подходящие под условие и составляет новую таблицу, имеющую колонки из обеих предыдущих и содержащую в соответствующих колонках данные из них.
Синтаксис: <table1> join <table2> on <condition>, где
- table1 и table2 - имена таблиц для объединения.
- condition - выражение, определяющее, какие пары записей брать.
Пример: пусть есть 2 таблицы users и posts:
id | login   | is_admin
1  | "vasya" | false
2  | "petya" | false
3  | "admin" | true
и
id | user_id | text
1  | 1       | "А"
2  | 1       | "B"
3  | 3       | "С"
Тoгдa select posts.id, users.login, posts.text from users join posts on users.id = posts.user_id where true
Должен вернуть
id | login   | text
1  | "vasya" | "A"
2  | "vasya" | "B"
3  | "admin" | "C"

Create index
Запрос создания индекса. Индексы никак не влияют на результат запросов, но могут менять время исполнения. Индекс создается по нескольким колонкам и позволяет базе в дальнейшем быстрее выполнять сравнения этих колонок. В нашей базе будет 2 вида индексов:
1. ordered - если такой был создан по колонке х то он позволяет быстро делать выборку, сравнивая значения этой колонки с чем-то. Например select … where x > 10. Естественно, ожидается, что это повлияет и на более сложные запросы с дополнительными условиями, например select … where x > 100 && x < 200 && y > x.
2. unordered создается по набору колонок и позволяет быстро отбирать строки, где весь этот набор равен чему-нибудь. Например, если создать такой индекс по колонкам х и у то ожидается, что запросы типа select … where x = 10 && y = 20 будут выполняться быстро. Аналогично предыдущему, условия могут быть и более сложными.
Мы будем считать, что индексы работают достаточно хорошо, если:

- для ordered - при наличии индекса по колонке х будет наблюдаться заметное ускорение при запросах с условиями вида (…) && (х < 1000) && (x > 500) && (…) (Естественно, порядок выражений может быть произвольным, вместо < и > могут идти другие сравнения, а вместо 1000 и 500 - другие значения, не обязательно числовые).
- для unordered - при наличии индекса по колонкам х, y, z будет наблюдаться заметное ускорение при запросах с условиями вида (…) && (x = 1) && (у = 2) && (z = 3) && (…). (Порядок выражений произвольный, значения могут быть другими).

Если в запросе можно применить несколько индексов то достаточно, чтобы был применен хотя бы один.
Hint: Возможно, тут пригодится STL…
Синтаксис: create <index_type> index on <table> by <columns>, где
- index_type - тип индекса
- table - имя таблицы
- columns - список колонок через запятую.
Примеры:
create ordered index on users by login
create unordered index on users by is_admin

Для всего этого задания можно добавить любые улучшения сверх описанного. Подойдут подзапросы, nullable колонки и 3 вида outer join, constexpr-запросы, ORM, structured binding на результат выборки, новые хитрые виды индексов и атрибутов, особо хорошая оптимизация и все, что может впечатлить проверяющего. Если ты что-то добавляешь, чего не было указано в задании - напиши об этом подробно, в коде сделай дополнительные пометки.

Весь функционал должен быть протестирован. Полно и чётко. За отсутствие тестов или неполное тестирование штрафы.

в настоящий момент структура проекта выглядит так:
memdb_project/
├── include/
│   └── memdb/
│       ├── core/
│       │   ├── Column.h
│       │   ├── Database.h
│       │   ├── DataType.h
│       │   ├── Expression.h
│       │   ├── ExpressionParser.h
│       │   ├── Index.h
│       │   ├── Lexer.h
│       │   ├── QueryExecutor.h
│       │   ├── QueryParser.h
│       │   ├── QueryResult.h
│       │   ├── QueryResultIterator.h
│       │   ├── ResultRow.h
│       │   ├── Row.h
│       │   ├── Table.h
│       │   ├── Value.h
│       │   ├── exceptions/
│       │   │	├── DatabaseException.h
│       │   │	└── TypeMismatchException.h
│       │   ├── structs/
│       │   │	├── Token.h
│       │   │	├── ColumnInfo.h
│       │   │	└── ParsedQuery.h
│       │   └── enums/
│       │    	├── TokenType.h
│       │    	├── ColumnAttributes.h
│       │   	└── Type.h
│       ├── dependencies/
│       │   └── json.hpp # nlohmann/json
│       └── api/
├── src/
│   └── core/
│       ├── Column.cpp
│       ├── Database.cpp
│       ├── DataType.cpp
│       ├── Expression.cpp
│       ├── ExpressionParser.cpp
│       ├── Index.cpp
│       ├── Lexer.cpp
│       ├── QueryExecutor.cpp
│       ├── QueryParser.cpp
│       ├── QueryResult.cpp
│       ├── QueryResultIterator.cpp
│       ├── ResultRow.cpp
│       ├── Row.cpp
│       ├── Table.cpp
│       └── Value.cpp
├── tests/
│   └── test_core/
│       ├── TestCreateTable.cpp
│       └── TestInsert.cpp
├── CMakeLists.txt
├── README.md
└── .gitignore

Column.h
```
#ifndef MEMDB_CORE_COLUMN_H
#define MEMDB_CORE_COLUMN_H

#include "memdb/core/DataType.h"
#include "memdb/core/Value.h"

#include "memdb/core/enums/ColumnAttribute.h"

#include <string>
#include <optional>
#include <vector>
#include <stdexcept>

namespace memdb {
namespace core {

class Column {
public:
    Column(const std::string& name, const DataType& type,
           const std::vector<ColumnAttribute>& attributes = {},
           const std::optional<Value>& default_value = std::nullopt);

    const std::string& get_name() const;
    const DataType& get_type() const;
    const std::vector<ColumnAttribute>& get_attributes() const;
    const std::optional<Value>& get_default_value() const;

    bool has_attribute(ColumnAttribute attribute) const;

    std::string to_string() const;

private:
    std::string name_;
    DataType type_;
    std::vector<ColumnAttribute> attributes_;
    std::optional<Value> default_value_;
};

} // namespace core
} // namespace memdb

#endif // MEMDB_CORE_COLUMN_H
```
Database.h
```
#ifndef MEMDB_CORE_DATABASE_H
#define MEMDB_CORE_DATABASE_H

#include "memdb/core/Table.h"
#include "memdb/core/Value.h"
#include "memdb/core/Column.h"
#include "memdb/core/Row.h"
#include "memdb/core/QueryParser.h"
#include "memdb/core/QueryExecutor.h"

#include "memdb/core/structs/ParsedQuery.h"

#include <string>
#include <unordered_map>
#include <memory>
#include <optional>
#include <vector>
#include <fstream>
#include <stdexcept>

namespace memdb {
namespace core {

class Database {
public:
    Database();

    void create_table(const std::string& table_name, const std::vector<Column>& columns);
    void drop_table(const std::string& table_name);
    std::shared_ptr<Table> get_table(const std::string& table_name) const;
    bool has_table(const std::string& table_name) const;

    RowID insert_row(const std::string& table_name, const std::vector<std::optional<Value>>& values);
    void delete_row(const std::string& table_name, core::RowID row_id);
    Row& get_row(const std::string& table_name, core::RowID row_id);
    const Row& get_row(const std::string& table_name, core::RowID row_id) const;

    const std::unordered_map<std::string, std::shared_ptr<Table>>& get_all_tables() const;
    void save_to_file(const std::string& filename) const;
    void load_from_file(const std::string& filename);

    QueryResult execute(const std::string& query);
    
    void create_index(const std::string& table_name, const std::string& index_type, const std::vector<std::string>& columns);

    std::string to_string() const;

private:
    std::unordered_map<std::string, std::shared_ptr<Table>> tables_;

    QueryParser parser_;
    QueryExecutor executor_;
};

} // namespace core
} // namespace memdb

#endif // MEMDB_CORE_DATABASE_H
```
DataType.h
```
#ifndef MEMDB_CORE_DATATYPE_H
#define MEMDB_CORE_DATATYPE_H

#include "memdb/core/enums/Type.h"

#include <string>
#include <variant>
#include <vector>
#include <cstdint>
#include <stdexcept>
#include <iostream>

namespace memdb {
namespace core {

class DataType {
public:
    DataType(Type type);
    DataType(Type type, size_t size); // for String[X] and Bytes[X]

    Type get_type() const;
    size_t get_size() const; // for String[X] adn Bytes[X]

    bool is_string() const;
    bool is_bytes() const;
    bool is_int32() const;
    bool is_bool() const;

    std::string to_string() const;

private:
    Type type_;
    size_t size_; // for String[X] adn Bytes[X]
};

} // namespace core
} // namespace memdb

#endif // MEMDB_CORE_DATATYPE_H
```
Expression.h
```
#ifndef MEMDB_CORE_EXPRESSION_H
#define MEMDB_CORE_EXPRESSION_H

#include "memdb/core/Value.h"
#include "memdb/core/DataType.h"

#include <memory>
#include <string>
#include <vector>
#include <unordered_map>

namespace memdb {
namespace core {

class Expression {
public:
    virtual ~Expression() = default;
    virtual DataType get_type() const = 0;
    virtual Value evaluate(const std::unordered_map<std::string, Value>& row) const = 0;
};

class LiteralExpression : public Expression {
public:
    LiteralExpression(const Value& value);
    DataType get_type() const override;
    Value evaluate(const std::unordered_map<std::string, Value>& row) const override;

private:
    Value value_;
};

class VariableExpression : public Expression {
public:
    VariableExpression(const std::string& name);
    DataType get_type() const override;
    Value evaluate(const std::unordered_map<std::string, Value>& row) const override;

    const std::string& get_name() const { return name_; }

private:
    std::string name_;
};

class UnaryExpression : public Expression {
public:
    enum class Operator {
        Not,
        Length
    };

    UnaryExpression(Operator op, std::unique_ptr<Expression> operand);
    DataType get_type() const override;
    Value evaluate(const std::unordered_map<std::string, Value>& row) const override;

private:
    Operator op_;
    std::unique_ptr<Expression> operand_;
};

class BinaryExpression : public Expression {
public:
    enum class Operator {
        Add,
        Subtract,
        Multiply,
        Divide,
        Modulo,
        Less,
        LessEqual,
        Greater,
        GreaterEqual,
        Equal,
        NotEqual,
        And,
        Or,
        Xor
    };

    BinaryExpression(Operator op, std::unique_ptr<Expression> left, std::unique_ptr<Expression> right);
    DataType get_type() const override;
    Value evaluate(const std::unordered_map<std::string, Value>& row) const override;

    Operator get_operator() const { return op_; }
    const Expression* get_left() const { return left_.get(); }
    const Expression* get_right() const { return right_.get(); }

private:
    Operator op_;
    std::unique_ptr<Expression> left_;
    std::unique_ptr<Expression> right_;
};

} // namespace core
} // namespace memdb

#endif // MEMDB_CORE_EXPRESSION_H
```
ExpressionParser.h
```
#ifndef MEMDB_CORE_EXPRESSIONPARSER_H
#define MEMDB_CORE_EXPRESSIONPARSER_H

#include "memdb/core/Expression.h"
#include "memdb/core/Lexer.h"

#include <memory>

namespace memdb {
namespace core {

class ExpressionParser {
public:
    explicit ExpressionParser(const std::string& input);
    std::unique_ptr<Expression> parse_expression();

private:
    std::unique_ptr<Expression> parse_logical_or();
    std::unique_ptr<Expression> parse_logical_and();
    std::unique_ptr<Expression> parse_logical_xor();
    std::unique_ptr<Expression> parse_equality();
    std::unique_ptr<Expression> parse_comparison();
    std::unique_ptr<Expression> parse_addition();
    std::unique_ptr<Expression> parse_term();
    std::unique_ptr<Expression> parse_factor();
    std::unique_ptr<Expression> parse_unary();
    std::unique_ptr<Expression> parse_primary();

    Lexer lexer_;
    Token current_token_;

    void consume(TokenType type, const std::string& error_message);
    bool match(TokenType type, const std::string& value = "");
    void advance();
};

} // namespace core
} // namespace memdb

#endif // MEMDB_CORE_EXPRESSIONPARSER_H
```
Index.h
```
#ifndef MEMDB_CORE_INDEX_H
#define MEMDB_CORE_INDEX_H

#include "memdb/core/Value.h"
#include "memdb/core/Row.h"

#include <vector>
#include <unordered_map>
#include <map>
#include <string>
#include <memory>

namespace memdb {
namespace core {

enum class IndexType {
    Ordered,
    Unordered
};

class Index {
public:
    Index(IndexType type, const std::vector<std::string>& columns);

    IndexType get_type() const { return type_; }
    const std::vector<std::string>& get_columns() const { return columns_; }

    void add_row(RowID row_id, const std::unordered_map<std::string, Value>& row);
    void remove_row(RowID row_id, const std::unordered_map<std::string, Value>& row);

    std::vector<RowID> search_unordered(const std::unordered_map<std::string, Value>& condition) const;
    std::vector<RowID> search_ordered(const std::string& column,
                                      const std::optional<Value>& lower,
                                      bool lower_inclusive,
                                      const std::optional<Value>& upper,
                                      bool upper_inclusive) const;

private:
    IndexType type_;
    std::vector<std::string> columns_;
    
    std::unordered_map<std::string, std::vector<RowID>> unordered_map_;
    std::map<std::string, RowID> ordered_map_;
};

} // namespace core
} // namespace memdb

#endif // MEMDB_CORE_INDEX_H
```
Lexer.h
```
#ifndef MEMDB_CORE_LEXER_H
#define MEMDB_CORE_LEXER_H

#include "memdb/core/structs/Token.h"

#include <string>
#include <vector>
#include <variant>
#include <cctype>

namespace memdb {
namespace core {

class Lexer {
public:
    explicit Lexer(const std::string& input);
    Token get_next_token();

private:
    char peek() const;
    char get_char();
    void skip_whitespace();
    Token identifier();
    Token number();
    Token string_literal();
    Token bytes_literal();
    
    std::string input_;
    size_t pos_;
};

} // namespace core
} // namespace memdb

#endif // MEMDB_CORE_LEXER_H
```
QueryExecutor.h
```
#ifndef MEMDB_CORE_QUERYEXECUTOR_H
#define MEMDB_CORE_QUERYEXECUTOR_H

#include "memdb/core/Expression.h"
#include "memdb/core/QueryResult.h"

#include "memdb/core/structs/ParsedQuery.h"

#include <memory>

namespace memdb {
namespace core {

class Database;

class QueryExecutor {
public:
    QueryResult execute(const ParsedQuery& parsed_query, Database& db);
    
private:
    QueryResult execute_select(const ParsedQuery& pq, Database& db);
    QueryResult execute_update(const ParsedQuery& pq, Database& db);
    QueryResult execute_delete(const ParsedQuery& pq, Database& db);
    QueryResult execute_create_index(const ParsedQuery& pq, Database& db);
};

} // namespace core
} // namespace memdb

#endif // MEMDB_CORE_QUERYEXECUTOR_H
```
QueryParser.h
```
#ifndef MEMDB_CORE_QUERYPARSER_H
#define MEMDB_CORE_QUERYPARSER_H

#include "memdb/core/Column.h"

#include "memdb/core/structs/ParsedQuery.h"

#include <string>
#include <memory>

namespace memdb {
namespace core {

class Database;

class QueryParser {
public:
    ParsedQuery parse(const std::string& query);
    bool validate_query(const std::string& query);

    void set_database(Database* db);

private:
    Database* db_ = nullptr;
    Column parse_column_definition(const std::string& col_def);
    std::vector<std::string> split_columns(const std::string& columns_def);
    std::string trim(const std::string& s);
};

} // namespace core
} // namespace memdb

#endif // MEMDB_CORE_QUERYPARSER_H
```
QueryResult.h
```
#ifndef MEMDB_CORE_QUERYRESULT_H
#define MEMDB_CORE_QUERYRESULT_H

#include "memdb/core/Value.h"
#include "memdb/core/QueryResultIterator.h"

#include "memdb/core/structs/ColumnInfo.h"

#include <vector>
#include <string>
#include <optional>
#include <iterator>

namespace memdb {
namespace core {

class QueryResult {
public:
    QueryResult() : success_(true) {}
    QueryResult(const std::vector<std::vector<std::optional<Value>>>& data) 
                                : success_(true), data_(data), columns_() {}
    QueryResult(const std::vector<std::vector<std::optional<Value>>>& data, 
                const std::vector<ColumnInfo>& columns) : success_(true), data_(data), columns_(columns) {}
    QueryResult(const std::string& error_message) : success_(false), error_message_(error_message) {}

    bool is_ok() const { return success_; }
    std::string get_error() const { return error_message_; }

    QueryResultIterator begin() const;
    QueryResultIterator end() const;

    const std::vector<std::vector<std::optional<Value>>>& get_data() const { return data_; }
    const std::vector<ColumnInfo>& get_columns() const { return columns_; }

    std::string to_string() const;
    void print(std::ostream& os = std::cout) const;

    friend std::ostream& operator<<(std::ostream& os, const QueryResult& result);

private:
    bool success_;
    std::string error_message_;
    std::vector<std::vector<std::optional<Value>>> data_;
    std::vector<ColumnInfo> columns_;

    void print_separator(std::ostringstream& ss, const std::vector<size_t>& widths) const;
    size_t get_max_value_width(size_t col_idx) const;
    static std::string type_to_string(Type type);
};

} // namespace core
} // namespace memdb

#endif // MEMDB_CORE_QUERYRESULT_H
```
QueryResultIterator.h
```
#ifndef MEMDB_CORE_QUERYRESULTITERATOR_H
#define MEMDB_CORE_QUERYRESULTITERATOR_H

#include "memdb/core/ResultRow.h"
#include "memdb/core/structs/ColumnInfo.h"
#include <vector>

namespace memdb {
namespace core {

class QueryResultIterator {
public:
    using DataIterator = std::vector<std::vector<std::optional<Value>>>::const_iterator;

    QueryResultIterator(DataIterator data_iter, const std::vector<ColumnInfo>& columns)
                        : data_iter_(data_iter), columns_(&columns) {}

    ResultRow operator*() const;
    QueryResultIterator& operator++();
    bool operator!=(const QueryResultIterator& other) const;

private:
    DataIterator data_iter_;
    const std::vector<ColumnInfo>* columns_;
};

} // namespace core
} // namespace memdb

#endif // MEMDB_CORE_QUERYRESULTITERATOR_H
```
ResultRow.h
```
#ifndef MEMDB_CORE_RESULTROW_H
#define MEMDB_CORE_RESULTROW_H

#include "memdb/core/Value.h"
#include "memdb/core/structs/ColumnInfo.h"

#include <vector>
#include <optional>
#include <unordered_map>
#include <string>

namespace memdb {
namespace core {

class ResultRow {
public:
    ResultRow(const std::vector<std::optional<Value>>& values, const std::vector<ColumnInfo>& columns);

    const std::optional<Value>& operator[](const std::string& column_name) const;

private:
    std::unordered_map<std::string, std::optional<Value>> row_map_;
};

} // namespace core
} // namespace memdb

#endif // MEMDB_CORE_RESULTROW_H
```
Row.h
```
#ifndef MEMDB_CORE_ROW_H
#define MEMDB_CORE_ROW_H

#include "memdb/core/Value.h"

#include <vector>
#include <optional>
#include <cstdint>
#include <stdexcept>

namespace memdb {
namespace core {

using RowID = uint32_t;

class Row {
public:
    Row(RowID id, const std::vector<std::optional<Value>>& values);

    RowID get_id() const;

    std::vector<std::optional<Value>>& get_values();
    const std::vector<std::optional<Value>>& get_values() const;

    std::optional<Value>& get_value(size_t index);
    const std::optional<Value>& get_value(size_t index) const;

    void set_value(size_t index, const Value& value);

private:
    RowID id_;
    std::vector<std::optional<Value>> values_;
};

} // namespace core
} // namespace memdb

#endif // MEMDB_CORE_ROW_H
```
Table.h
```
#ifndef MEMDB_CORE_TABLE_H
#define MEMDB_CORE_TABLE_H

#include "memdb/core/Column.h"
#include "memdb/core/DataType.h"
#include "memdb/core/Row.h"
#include "memdb/core/Value.h"
#include "memdb/core/Index.h"
#include "memdb/core/Expression.h"

#include <string>
#include <vector>
#include <unordered_map>
#include <optional>
#include <memory>
#include <stdexcept>
#include <cstdint>
#include <json.hpp>


namespace memdb {
namespace core {

class Table {
public:
    Table(const std::string& name, const std::vector<Column>& columns);

    const std::string& get_name() const;
    const std::vector<Column>& get_columns() const;
    size_t get_column_index(const std::string& column_name) const;

    void add_column(const Column& column);
    bool has_column(const std::string& column_name) const;

    RowID insert_row(const std::vector<std::optional<Value>>& values);
    RowID insert_row(const std::vector<std::optional<Value>>& values, RowID id);
    void delete_row(RowID id);
    Row& get_row(RowID id);
    const Row& get_row(RowID id) const;
    const std::unordered_map<RowID, Row>& get_all_rows() const;
    std::unordered_map<RowID, Row>& get_all_rows();
    const std::vector<std::unique_ptr<Index>>& get_indexes() const { return indexes_; }

    void add_index(const std::string& index_type_str, const std::vector<std::string>& columns);
    std::vector<RowID> find_rows(const std::unique_ptr<Expression>& condition) const;

    void validate_row(const std::vector<std::optional<Value>>& values) const;

    nlohmann::json to_json() const;
    static Table from_json(const nlohmann::json& j);

    std::string to_string() const;

private:
    std::string name_;
    std::vector<Column> columns_;
    std::unordered_map<RowID, Row> rows_;
    std::vector<std::unique_ptr<Index>> indexes_;
    RowID next_row_id_;
};

} // namespace core
} // namespace memdb

#endif // MEMDB_CORE_TABLE_H
```
Value.h
```
#ifndef MEMDB_CORE_VALUE_H
#define MEMDB_CORE_VALUE_H

#include "memdb/core/enums/Type.h"

#include <string>
#include <variant>
#include <vector>
#include <cstdint>
#include <optional>
#include <stdexcept>
#include <iostream>

namespace memdb {
namespace core {

class Value {
public:
    Value() = default;
    Value(int32_t int_val);
    Value(bool bool_val);
    Value(const std::string& str_val);
    Value(const std::vector<uint8_t>& bytes_val);

    Type get_type() const;
    bool has_value() const;

    int32_t get_int() const;
    bool get_bool() const;
    const std::string& get_string() const;
    const std::vector<uint8_t>& get_bytes() const;

    const std::variant<int32_t, bool, std::string, std::vector<uint8_t>>& get_variant() const;
    std::variant<int32_t, bool, std::string, std::vector<uint8_t>>& get_variant();

    void set_int(int32_t int_val);
    void set_bool(bool bool_val);
    void set_string(const std::string& str_val);
    void set_bytes(const std::vector<uint8_t>& bytes_val);

    std::string to_string() const;

private:
    std::optional<std::variant<int32_t, bool, std::string, std::vector<uint8_t>>> data_;
};

} // namespace core
} // namespace memdb

#endif // MEMDB_CORE_VALUE_H
```
enums/ColumnAttribute.h
#ifndef MEMDB_CORE_ENUMS_COLUMNATTRIBUTE_H
#define MEMDB_CORE_ENUMS_COLUMNATTRIBUTE_H

namespace memdb {
namespace core {

enum class ColumnAttribute {
    Unique,
    AutoIncrement,
    Key
};

} // namespace core
} // namespace memdb

#endif // MEMDB_CORE_ENUMS_COLUMNATTRIBUTE_H
```
enums/TokenType.h
```
#ifndef MEMDB_CORE_ENUMS_TOKENTYPE_H
#define MEMDB_CORE_ENUMS_TOKENTYPE_H

namespace memdb {
namespace core {

enum class TokenType {
    Identifier,
    IntLiteral,
    BoolLiteral,
    StringLiteral,
    BytesLiteral,
    Operator,
    Length,
    Comma,
    LeftParen,
    RightParen,
    EndOfInput
};

} // namespace core
} // namespace memdb

#endif // MEMDB_CORE_ENUMS_TOKENTYPE_H
```
enums/Type.h
```
#ifndef MEMDB_CORE_ENUMS_TYPE_H
#define MEMDB_CORE_ENUMS_TYPE_H

namespace memdb {
namespace core {

enum class Type {
    Int32,
    Bool,
    String,
    Bytes,
    Unknown
};

} // namespace core
} // namespace memdb

#endif // MEMDB_CORE_ENUMS_TYPE_H
```
exceptions/DatabaseException.h
```
#ifndef MEMDB_CORE_EXCEPTIONS_DATABASEEXCEPTION_H
#define MEMDB_CORE_EXCEPTIONS_DATABASEEXCEPTION_H

#include <stdexcept>
#include <string>

namespace memdb {
namespace core {
namespace exceptions {

class DatabaseException : public std::runtime_error {
public:
    explicit DatabaseException(const std::string& message)
        : std::runtime_error(message) {}
};

class TableNotFoundException : public DatabaseException {
public:
    explicit TableNotFoundException(const std::string& table_name)
        : DatabaseException("Table not found: " + table_name) {}
};

class TableAlreadyExistsException : public DatabaseException {
public:
    explicit TableAlreadyExistsException(const std::string& table_name)
        : DatabaseException("Table already exists: " + table_name) {}
};

class RowNotFoundException : public DatabaseException {
public:
    explicit RowNotFoundException(core::RowID row_id)
        : DatabaseException("Row ID not found: " + std::to_string(row_id)) {}
};

class SerializationException : public DatabaseException {
public:
    explicit SerializationException(const std::string& message)
        : DatabaseException("Serialization Error: " + message) {}
};

} // namespace exceptions
} // namespace core
} // namespace memdb

#endif // MEMDB_CORE_EXCEPTIONS_DATABASEEXCEPTION_H
```
exceptions/TypeMismatchException.h
```
#ifndef MEMDB_CORE_EXCEPTIONS_TYPEMISMATCHEXCEPTION_H
#define MEMDB_CORE_EXCEPTIONS_TYPEMISMATCHEXCEPTION_H

#include <stdexcept>
#include <string>

namespace memdb {
namespace core {
namespace exceptions {

class TypeMismatchException : public std::runtime_error {
public:
    explicit TypeMismatchException(const std::string& message)
        : std::runtime_error(message) {}
};

} // namespace exceptions
} // namespace core
} // namespace memdb

#endif // MEMDB_CORE_EXCEPTIONS_TYPEMISMATCHEXCEPTION_H
```
structs/ColumnInfo.h
```
#ifndef MEMDB_CORE_STRUCTS_COLUMNINFO_H
#define MEMDB_CORE_STRUCTS_COLUMNINFO_H

#include "memdb/core/enums/Type.h"
#include "memdb/core/DataType.h"

#include <string>

namespace memdb {
namespace core {

struct ColumnInfo {
    std::string name;
    DataType type;

    ColumnInfo(const std::string& name_, Type type_) : name(name_), type(type_) {}
    ColumnInfo(const std::string& name_, const DataType& data_type) : name(name_), type(data_type) {} 

    const std::string& get_name() const { return name; }

    Type get_type() const { return type.get_type(); }
};

} // namespace core
} // namespace memdb

#endif // MEMDB_CORE_STRUCTS_COLUMNINFO_H
```
structs/ParsedQuery.h
```
#ifndef MEMDB_CORE_STRUCTS_PARSEDQUERY_H
#define MEMDB_CORE_STRUCTS_PARSEDQUERY_H

#include "memdb/core/Column.h"
#include "memdb/core/Value.h"
#include "memdb/core/Expression.h"

#include <string>
#include <vector>
#include <optional>
#include <unordered_map>

namespace memdb {
namespace core {

struct ParsedQuery {
    enum class QueryType {
        CreateTable,
        Insert,
        Select,
        Update,
        Delete,
        CreateIndex,
    } type;

    std::string table_name;
    std::string table_alias;
    std::vector<Column> columns;

    std::optional<std::vector<std::optional<Value>>> insert_values;
    std::optional<std::unordered_map<std::string, Value>> insert_named_values;

    struct SelectItem {
        std::unique_ptr<Expression> expression;
        std::string alias; // Optional alias; can be empty if no alias is specified
    };
    std::vector<SelectItem> select_items;
    
    std::unique_ptr<Expression> where_clause;

    std::unordered_map<std::string, std::unique_ptr<Expression>> update_assignments;
    std::unique_ptr<Expression> update_where_clause;

    std::unique_ptr<Expression> delete_where_clause;

    std::string from_table;

    std::string index_type;
    std::vector<std::string> index_columns;

    struct JoinInfo {
        std::string table_name;
        std::string table_alias;
        std::unique_ptr<Expression> join_condition;
    };
    std::vector<JoinInfo> joins;

    // TODO: other fields if needed
};

} // namespace core
} // namespace memdb

#endif // MEMDB_CORE_STRUCTS_PARSEDQUERY_H
```
structs/Token.h
```
#ifndef MEMDB_CORE_STRUCTS_TOKEN_H
#define MEMDB_CORE_STRUCTS_TOKEN_H

#include "memdb/core/enums/TokenType.h"

#include <string>

namespace memdb {
namespace core {

struct Token {
    TokenType type;
    std::string value;
};

} // namespace core
} // namespace memdb

#endif // MEMDB_CORE_STRUCTS_TOKEN_H
```
Column.cpp
```
#include "memdb/core/Column.h"

namespace memdb {
namespace core {

// ======= Column Implementation =======

Column::Column(const std::string& name, const DataType& type,
               const std::vector<ColumnAttribute>& attributes,
               const std::optional<Value>& default_value)
    : name_(name), type_(type), attributes_(attributes), default_value_(default_value) {

    if (name.empty()) {
        throw std::invalid_argument("Column name cannot be empty.");
    }

    for (const auto& attr : attributes_) {
        if (attr == ColumnAttribute::AutoIncrement && !type_.is_int32()) {
            throw std::invalid_argument("AutoIncrement attribute can only be applied to int32 columns.");
        }
    }

    if (default_value_) {
        if (default_value_->get_type() != type_.get_type()) {
            throw std::invalid_argument("Default value type does not match column type.");
        }

        // for String and Bytes
        if (type_.is_string()) {
            if (default_value_->get_string().size() > type_.get_size()) {
                throw std::invalid_argument("Default string value exceeds defined size.");
            }
        } else if (type_.is_bytes()) {
            if (default_value_->get_bytes().size() > type_.get_size()) {
                throw std::invalid_argument("Default bytes value exceeds defined size.");
            }
        }
    }
}

const std::string& Column::get_name() const {
    return name_;
}

const DataType& Column::get_type() const {
    return type_;
}

const std::vector<ColumnAttribute>& Column::get_attributes() const {
    return attributes_;
}

const std::optional<Value>& Column::get_default_value() const {
    return default_value_;
}

bool Column::has_attribute(ColumnAttribute attribute) const {
    for (const auto& attr : attributes_) {
        if (attr == attribute) {
            return true;
        }
    }
    return false;
}

std::string Column::to_string() const {
    std::string attr_str;
    if (!attributes_.empty()) {
        attr_str += "{";
        for (size_t i = 0; i < attributes_.size(); ++i) {
            switch (attributes_[i]) {
                case ColumnAttribute::Unique:
                    attr_str += "unique";
                    break;
                case ColumnAttribute::AutoIncrement:
                    attr_str += "autoincrement";
                    break;
                case ColumnAttribute::Key:
                    attr_str += "key";
                    break;
                default:
                    attr_str += "unknown";
            }
            if (i < attributes_.size() - 1) {
                attr_str += ", ";
            }
        }
        attr_str += "} ";
    }

    std::string default_str = "";
    if (default_value_) {
        default_str = " = " + default_value_->to_string();
    }

    return attr_str + name_ + " : " + type_.to_string() + default_str;
}

} // namespace core
} // namespace memdb
```
Database.cpp
```
#include "memdb/core/Database.h"

#include "memdb/core/exceptions/DatabaseException.h"

#include <fstream>
#include <json.hpp>

namespace memdb {
namespace core {

using json = nlohmann::json;

// ======= Database Implementation =======

Database::Database() = default;

void Database::create_table(const std::string& table_name, const std::vector<Column>& columns) {
    if (has_table(table_name)) {
        throw exceptions::TableAlreadyExistsException(table_name);
    }
    auto table = std::make_shared<Table>(table_name, columns);
    tables_.emplace(table_name, table);
}

void Database::drop_table(const std::string& table_name) {
    auto it = tables_.find(table_name);
    if (it != tables_.end()) {
        tables_.erase(it);
    } else {
        throw exceptions::TableNotFoundException(table_name);
    }
}

std::shared_ptr<Table> Database::get_table(const std::string& table_name) const {
    auto it = tables_.find(table_name);
    if (it != tables_.end()) {
        return it->second;
    }
    throw exceptions::TableNotFoundException(table_name);
}

bool Database::has_table(const std::string& table_name) const {
    return tables_.find(table_name) != tables_.end();
}

RowID Database::insert_row(const std::string& table_name, const std::vector<std::optional<Value>>& values) {
    auto table = get_table(table_name);
    if (!table) {
        throw std::invalid_argument("Table does not exist: " + table_name);
    }

    const auto& columns = table->get_columns();
    std::vector<std::optional<Value>> final_values;
    final_values.reserve(columns.size());

    // Validate types and sizes
    for (size_t i = 0; i < columns.size(); i++) {
        const auto& column = columns[i];
        
        if (i >= values.size() || !values[i].has_value()) {
            if (column.has_attribute(ColumnAttribute::AutoIncrement)) {
                final_values.emplace_back(); // Leave empty for auto-increment
                continue;
            }
            if (column.get_default_value().has_value()) {
                final_values.emplace_back(column.get_default_value());
                continue;
            }
            throw std::invalid_argument("Missing value for column: " + column.get_name());

        }

        const auto& value = values[i].value();
        
        if (value.get_type() != column.get_type().get_type()) {
            throw std::invalid_argument("Invalid type for column '" + column.get_name() + "'");
        }

        if (column.get_type().get_type() == Type::String || 
            column.get_type().get_type() == Type::Bytes) {
            size_t value_size = (column.get_type().get_type() == Type::String) ? 
                                value.get_string().size() : 
                                value.get_bytes().size();
            if (value_size > column.get_type().get_size()) {
                std::string type_of_str = (column.get_type().get_type() == Type::String ? "String" : "Bytes");
                throw std::invalid_argument(
                    type_of_str +
                    " value exceeds defined size of " + std::to_string(column.get_type().get_size()) +
                    " for column \"" + column.get_name() + "\"");
            }
        }
        
        final_values.push_back(values[i]);
    }

    return table->insert_row(values);
}

void Database::delete_row(const std::string& table_name, core::RowID row_id) {
    auto table = get_table(table_name);
    table->delete_row(row_id);
}

Row& Database::get_row(const std::string& table_name, core::RowID row_id) {
    auto table = get_table(table_name);
    return table->get_row(row_id);
}

const Row& Database::get_row(const std::string& table_name, core::RowID row_id) const {
    auto table = get_table(table_name);
    return table->get_row(row_id);
}

const std::unordered_map<std::string, std::shared_ptr<Table>>& Database::get_all_tables() const {
    return tables_;
}

void Database::save_to_file(const std::string& filename) const {
    json j;
    j["tables"] = json::array();
    for (const auto& [name, table] : tables_) {
        j["tables"].push_back(table->to_json());
    }
    std::ofstream ofs(filename, std::ios::binary);
    if (!ofs) {
        throw exceptions::SerializationException("Failed to open file for saving: " + filename);
    }
    ofs << j.dump(4);
}

void Database::load_from_file(const std::string& filename) {
    std::ifstream ifs(filename, std::ios::binary);
    if (!ifs) {
        throw exceptions::SerializationException("Failed to open file for loading: " + filename);
    }
    json j;
    ifs >> j;
    if (!j.contains("tables")) {
        throw exceptions::SerializationException("Invalid database file format.");
    }
    for (const auto& table_json : j["tables"]) {
        Table table = Table::from_json(table_json);
        auto table_ptr = std::make_shared<Table>(std::move(table));
        tables_.emplace(table_ptr->get_name(), table_ptr);
    }
}

void Database::create_index(const std::string& table_name, const std::string& index_type, const std::vector<std::string>& columns) {
    auto table = get_table(table_name);
    table->add_index(index_type, columns);
}

std::string Database::to_string() const {
    std::string db_str = "Database:\n";
    for (const auto& [name, table] : tables_) {
        db_str += table->to_string() + "\n";
    }
    return db_str;
}

QueryResult Database::execute(const std::string& query) {
    try {
        auto parsed_query = parser_.parse(query);
        return executor_.execute(parsed_query, *this);
    }
    catch (const std::invalid_argument& e) {
        return QueryResult(e.what());
    }
    catch (const exceptions::DatabaseException& e) {
        return QueryResult(e.what());
    }
    catch (const std::exception& e) {
        return QueryResult(std::string("Standard exception: ") + e.what());
    }
    catch (...) {
        return QueryResult("Unknown error during query execution.");
    }
}

} // namespace core
} // namespace memdb
```
DataType.cpp
```
#include "memdb/core/DataType.h"

namespace memdb {
namespace core {

// ======= DataType Implementation =======

DataType::DataType(Type type) : type_(type), size_(0) {
    if ((type_ != Type::String && type_ != Type::Bytes) && size_ != 0) {
        throw std::invalid_argument("Size can only be set for String and Bytes types.");
    }
}

DataType::DataType(Type type, size_t size) : type_(type), size_(size) {
    if ((type_ != Type::String && type_ != Type::Bytes) || size_ == 0) {
        throw std::invalid_argument("Size can only be set for String and Bytes types with size > 0.");
    }
}

Type DataType::get_type() const {
    return type_;
}

size_t DataType::get_size() const {
    if (!is_string() && !is_bytes()) {
        throw std::logic_error("Only String and Bytes types have size.");
    }
    return size_;
}

bool DataType::is_string() const {
    return type_ == Type::String;
}

bool DataType::is_bytes() const {
    return type_ == Type::Bytes;
}

bool DataType::is_int32() const {
    return type_ == Type::Int32;
}

bool DataType::is_bool() const {
    return type_ == Type::Bool;
}

std::string DataType::to_string() const {
    switch (type_) {
        case Type::Int32:
            return "int32";
        case Type::Bool:
            return "bool";
        case Type::String:
            return "string[" + std::to_string(size_) + "]";
        case Type::Bytes:
            return "bytes[" + std::to_string(size_) + "]";
        default:
            return "unknown";
    }
}

} // namespace core
} // namespace memdb
```
Expression.cpp
```
#include "memdb/core/Expression.h"
#include "memdb/core/exceptions/TypeMismatchException.h"

#include <stdexcept>
#include <cmath>

namespace memdb {
namespace core {

int compare_values(const Value& left_val, const Value& right_val) {
    if (left_val.get_type() != right_val.get_type()) {
        throw exceptions::TypeMismatchException("Comparison requires operands of the same type.");
    }

    switch (left_val.get_type()) {
        case Type::Int32:
            return (left_val.get_int() < right_val.get_int()) ? -1 :
                   (left_val.get_int() > right_val.get_int()) ? 1 : 0;

        case Type::Bool:
            return (left_val.get_bool() == right_val.get_bool()) ? 0 :
                   (left_val.get_bool() == false) ? -1 : 1;

        case Type::String:
            return left_val.get_string().compare(right_val.get_string());

        case Type::Bytes:
            if (left_val.get_bytes() == right_val.get_bytes()) {
                return 0;
            } else if (left_val.get_bytes() < right_val.get_bytes()) {
                return -1;
            } else {
                return 1;
            }

        default:
            throw std::runtime_error("Unsupported type for comparison operations.");
    }
}

// ======= LiteralExpression Implementation =======
LiteralExpression::LiteralExpression(const Value& value) : value_(value) {}

Value LiteralExpression::evaluate(const std::unordered_map<std::string, Value>& row) const {
    return value_;
}

DataType LiteralExpression::get_type() const {
    return value_.get_type();
}

// ======= VariableExpression Implementation =======
VariableExpression::VariableExpression(const std::string& name) : name_(name) {}

Value VariableExpression::evaluate(const std::unordered_map<std::string, Value>& row) const {
    auto it = row.find(name_);
    if (it == row.end()) {
        throw exceptions::TypeMismatchException("Column not found: " + name_);
    }
    if (!it->second.has_value()) {
        throw exceptions::TypeMismatchException("NULL value for column: " + name_);
    }
    return it->second;
}

DataType VariableExpression::get_type() const {
    return Type::Unknown;
}

// ======= UnaryExpression Implementation =======
UnaryExpression::UnaryExpression(Operator op, std::unique_ptr<Expression> operand)
    : op_(op), operand_(std::move(operand)) {}

Value UnaryExpression::evaluate(const std::unordered_map<std::string, Value>& row) const {
    Value val = operand_->evaluate(row);
    switch (op_) {
        case Operator::Not:
            if (val.get_type() != Type::Bool) {
                throw exceptions::TypeMismatchException("Operator '!' requires Bool type.");
            }
            return Value(!val.get_bool());
        case Operator::Length:
            if (val.get_type() == Type::String) {
                return Value(static_cast<int32_t>(val.get_string().size()));
            } else if (val.get_type() == Type::Bytes) {
                return Value(static_cast<int32_t>(val.get_bytes().size()));
            } else {
                throw exceptions::TypeMismatchException("Operator '|var|' requires String or Bytes type.");
            }
        default:
            throw std::runtime_error("Unknown unary operator.");
    }
}

DataType UnaryExpression::get_type() const {
    switch (op_) {
        case Operator::Not:
            return Type::Bool;
        case Operator::Length:
            return Type::Int32;
        default:
            return Type::Unknown;
    }
}

// ======= BinaryExpression Implementation =======
BinaryExpression::BinaryExpression(Operator op, std::unique_ptr<Expression> left, std::unique_ptr<Expression> right)
    : op_(op), left_(std::move(left)), right_(std::move(right)) {}

Value BinaryExpression::evaluate(const std::unordered_map<std::string, Value>& row) const {
    Value left_val = left_->evaluate(row);
    Value right_val = right_->evaluate(row);

    switch (op_) {
        case Operator::Add:
            if (left_val.get_type() == Type::Int32 && right_val.get_type() == Type::Int32) {
                return Value(left_val.get_int() + right_val.get_int());
            }
            if (left_val.get_type() == Type::String && right_val.get_type() == Type::String) {
                return Value(left_val.get_string() + right_val.get_string());
            }
            throw exceptions::TypeMismatchException("Operator '+' not supported for given types.");

        case Operator::Subtract:
            if (left_val.get_type() == Type::Int32 && right_val.get_type() == Type::Int32) {
                return Value(left_val.get_int() - right_val.get_int());
            }
            throw exceptions::TypeMismatchException("Operator '-' requires numeric types.");

        case Operator::Multiply:
            if (left_val.get_type() == Type::Int32 && right_val.get_type() == Type::Int32) {
                return Value(left_val.get_int() * right_val.get_int());
            }
            throw exceptions::TypeMismatchException("Operator '*' requires numeric types.");

        case Operator::Divide:
            if (left_val.get_type() == Type::Int32 && right_val.get_type() == Type::Int32) {
                if (right_val.get_int() == 0) throw exceptions::TypeMismatchException("Division by zero.");
                return Value(left_val.get_int() / right_val.get_int());
            }
            throw exceptions::TypeMismatchException("Operator '/' requires numeric types.");

        case Operator::Modulo:
            if (left_val.get_type() == Type::Int32 && right_val.get_type() == Type::Int32) {
                if (right_val.get_int() == 0) throw exceptions::TypeMismatchException("Modulo by zero.");
                return Value(left_val.get_int() % right_val.get_int());
            }
            throw exceptions::TypeMismatchException("Operator '%' requires integer types.");

                case Operator::Less:
            if (left_val.get_type() != right_val.get_type()) {
                throw exceptions::TypeMismatchException("Comparison requires operands of the same type.");
            }
            return Value(compare_values(left_val, right_val) < 0);

        case Operator::LessEqual:
            if (left_val.get_type() != right_val.get_type()) {
                throw exceptions::TypeMismatchException("Comparison requires operands of the same type.");
            }
            return Value(compare_values(left_val, right_val) <= 0);

        case Operator::Greater:
            if (left_val.get_type() != right_val.get_type()) {
                throw exceptions::TypeMismatchException("Comparison requires operands of the same type.");
            }
            return Value(compare_values(left_val, right_val) > 0);

        case Operator::GreaterEqual:
            if (left_val.get_type() != right_val.get_type()) {
                throw exceptions::TypeMismatchException("Comparison requires operands of the same type.");
            }
            return Value(compare_values(left_val, right_val) >= 0);

        case Operator::Equal:
            if (left_val.get_type() != right_val.get_type()) {
                throw exceptions::TypeMismatchException("Equality comparison requires operands of the same type.");
            }
            return Value(compare_values(left_val, right_val) == 0);

        case Operator::NotEqual:
            if (left_val.get_type() != right_val.get_type()) {
                throw exceptions::TypeMismatchException("Inequality comparison requires operands of the same type.");
            }
            return Value(compare_values(left_val, right_val) != 0);

        case Operator::And:
            if (left_val.get_type() != Type::Bool || right_val.get_type() != Type::Bool) {
                throw exceptions::TypeMismatchException("Operator '&&' requires Bool types.");
            }
            return Value(left_val.get_bool() && right_val.get_bool());

        case Operator::Or:
            if (left_val.get_type() != Type::Bool || right_val.get_type() != Type::Bool) {
                throw exceptions::TypeMismatchException("Operator '||' requires Bool types.");
            }
            return Value(left_val.get_bool() || right_val.get_bool());

        case Operator::Xor:
            if (left_val.get_type() != Type::Bool || right_val.get_type() != Type::Bool) {
                throw exceptions::TypeMismatchException("Operator '^^' requires Bool types.");
            }
            return Value(static_cast<bool>(left_val.get_bool() ^ right_val.get_bool()));

        default:
            throw std::runtime_error("Unknown binary operator.");
    }
}

DataType BinaryExpression::get_type() const {
    switch (op_) {
        case Operator::Add:
        case Operator::Subtract:
        case Operator::Multiply:
        case Operator::Divide:
        case Operator::Modulo:
            return Type::Int32;
        case Operator::Less:
        case Operator::LessEqual:
        case Operator::Greater:
        case Operator::GreaterEqual:
        case Operator::Equal:
        case Operator::NotEqual:
        case Operator::And:
        case Operator::Or:
        case Operator::Xor:
            return Type::Bool;
        default:
            return Type::Unknown;
    }
}

} // namespace core
} // namespace memdb
```
ExpressionParser.cpp
```
#include "memdb/core/ExpressionParser.h"
#include "memdb/core/exceptions/TypeMismatchException.h"

#include <stdexcept>
#include <limits>
#include <numeric>

namespace memdb {
namespace core {

ExpressionParser::ExpressionParser(const std::string& input) : lexer_(input) {
    advance();
}

void ExpressionParser::advance() {
    current_token_ = lexer_.get_next_token();
}

void ExpressionParser::consume(TokenType type, const std::string& error_message) {
    if (current_token_.type != type) {
        throw exceptions::TypeMismatchException(error_message);
    }
    advance();
}

bool ExpressionParser::match(TokenType type, const std::string& value) {
    if (current_token_.type == type) {
        if (value.empty() || current_token_.value == value) {
            return true;
        }
    }
    return false;
}

std::unique_ptr<Expression> ExpressionParser::parse_expression() {
    return parse_logical_or();
}

std::unique_ptr<Expression> ExpressionParser::parse_logical_or() {
    auto node = parse_logical_xor();
    while (match(TokenType::Operator, "||")) {
        std::string op = current_token_.value;
        advance();
        auto right = parse_logical_and();
        node = std::make_unique<BinaryExpression>(BinaryExpression::Operator::Or, std::move(node), std::move(right));
    }
    return node;
}

std::unique_ptr<Expression> ExpressionParser::parse_logical_xor() {
    auto node = parse_logical_and();
    while (match(TokenType::Operator, "^^")) {
        std::string op = current_token_.value;
        advance();
        auto right = parse_logical_and();
        node = std::make_unique<BinaryExpression>(BinaryExpression::Operator::Xor, std::move(node), std::move(right));
    }
    return node;
}

std::unique_ptr<Expression> ExpressionParser::parse_logical_and() {
    auto node = parse_equality();
    while (match(TokenType::Operator, "&&")) {
        std::string op = current_token_.value;
        advance();
        auto right = parse_equality();
        node = std::make_unique<BinaryExpression>(BinaryExpression::Operator::And, std::move(node), std::move(right));
    }
    return node;
}

std::unique_ptr<Expression> ExpressionParser::parse_equality() {
    auto node = parse_comparison();
    while (match(TokenType::Operator, "==") || match(TokenType::Operator, "!=") || match(TokenType::Operator, "=")) {
        std::string op = current_token_.value;
        advance();
        auto right = parse_comparison();
        if (op == "==" || op == "=") {
            node = std::make_unique<BinaryExpression>(BinaryExpression::Operator::Equal, std::move(node), std::move(right));
        } else if (op == "!=") {
            node = std::make_unique<BinaryExpression>(BinaryExpression::Operator::NotEqual, std::move(node), std::move(right));
        } else {
            throw std::runtime_error("Unknown equality operator: " + op);
        }
    }
    return node;
}

std::unique_ptr<Expression> ExpressionParser::parse_comparison() {
    auto node = parse_term();
    while (match(TokenType::Operator, "<") || match(TokenType::Operator, "<=") ||
           match(TokenType::Operator, ">") || match(TokenType::Operator, ">=")) {
        std::string op = current_token_.value;
        advance();
        auto right = parse_term();
        if (op == "<") {
            node = std::make_unique<BinaryExpression>(BinaryExpression::Operator::Less, std::move(node), std::move(right));
        } else if (op == "<=") {
            node = std::make_unique<BinaryExpression>(BinaryExpression::Operator::LessEqual, std::move(node), std::move(right));
        } else if (op == ">") {
            node = std::make_unique<BinaryExpression>(BinaryExpression::Operator::Greater, std::move(node), std::move(right));
        } else if (op == ">=") {
            node = std::make_unique<BinaryExpression>(BinaryExpression::Operator::GreaterEqual, std::move(node), std::move(right));
        }
    }
    return node;
}

std::unique_ptr<Expression> ExpressionParser::parse_term() {
    auto node = parse_factor();
    while (match(TokenType::Operator, "+") || match(TokenType::Operator, "-")) {
        std::string op = current_token_.value;
        advance();
        auto right = parse_factor();
        if (op == "+") {
            node = std::make_unique<BinaryExpression>(BinaryExpression::Operator::Add, std::move(node), std::move(right));
        } else {
            node = std::make_unique<BinaryExpression>(BinaryExpression::Operator::Subtract, std::move(node), std::move(right));
        }
    }
    return node;
}

std::unique_ptr<Expression> ExpressionParser::parse_factor() {
    auto node = parse_unary();
    while (match(TokenType::Operator, "*") || match(TokenType::Operator, "/") || match(TokenType::Operator, "%")) {
        std::string op = current_token_.value;
        advance();
        auto right = parse_unary();
        if (op == "*") {
            node = std::make_unique<BinaryExpression>(BinaryExpression::Operator::Multiply, std::move(node), std::move(right));
        } else if (op == "/") {
            node = std::make_unique<BinaryExpression>(BinaryExpression::Operator::Divide, std::move(node), std::move(right));
        } else if (op == "%") {
            node = std::make_unique<BinaryExpression>(BinaryExpression::Operator::Modulo, std::move(node), std::move(right));
        }
    }
    return node;
}

std::unique_ptr<Expression> ExpressionParser::parse_unary() {
    if (match(TokenType::Operator, "!")) {
        advance();
        auto operand = parse_unary();
        return std::make_unique<UnaryExpression>(UnaryExpression::Operator::Not, std::move(operand));
    }

    return parse_primary();
}

std::unique_ptr<Expression> ExpressionParser::parse_primary() {
    if (match(TokenType::Length)) {
        std::string var_name = current_token_.value;
        advance();

        auto var_expr = std::make_unique<VariableExpression>(var_name);

        return std::make_unique<UnaryExpression>(UnaryExpression::Operator::Length, std::move(var_expr));
    }

    if (match(TokenType::LeftParen)) {
        advance();
        auto expr = parse_expression();
        consume(TokenType::RightParen, "Expected ')' after expression.");
        return expr;
    }

    if (match(TokenType::IntLiteral)) {
        int32_t value = std::stoll(current_token_.value);
        advance();
        return std::make_unique<LiteralExpression>(Value(static_cast<int32_t>(value)));
    }

    if (match(TokenType::BoolLiteral)) {
        bool value = (current_token_.value == "true");
        advance();
        return std::make_unique<LiteralExpression>(Value(value));
    }

    if (match(TokenType::StringLiteral)) {
        std::string value = current_token_.value;
        advance();
        return std::make_unique<LiteralExpression>(Value(value));
    }

    if (match(TokenType::BytesLiteral)) {
        std::string hex_str = current_token_.value;
        advance();
        std::vector<uint8_t> bytes;
        if (hex_str.size() < 2 || (hex_str[0] != '0' && hex_str[1] != 'x' && hex_str[1] != 'X')) {
            throw exceptions::TypeMismatchException("Invalid bytes literal.");
        }
        hex_str = hex_str.substr(2);
        if (hex_str.size() % 2 != 0) {
            throw exceptions::TypeMismatchException("Invalid bytes literal length.");
        }
        for (size_t i = 0; i < hex_str.size(); i += 2) {
            std::string byte_str = hex_str.substr(i, 2);
            uint8_t byte = static_cast<uint8_t>(std::stoi(byte_str, nullptr, 16));
            bytes.push_back(byte);
        }
        return std::make_unique<LiteralExpression>(Value(bytes));
    }

    if (match(TokenType::Identifier)) {
        std::string name = current_token_.value;
        advance();
        return std::make_unique<VariableExpression>(name);
    }

    throw exceptions::TypeMismatchException("Unexpected token in expression.");
}

} // namespace core
} // namespace memdb
```
Index.cpp
```
#include "memdb/core/Index.h"

#include "memdb/core/exceptions/DatabaseException.h"

#include <algorithm>

namespace memdb {
namespace core {

// ======= Index Implementation =======

Index::Index(IndexType type, const std::vector<std::string>& columns)
    : type_(type), columns_(columns) {}

void Index::add_row(RowID row_id, const std::unordered_map<std::string, Value>& row) {
    if (type_ == IndexType::Unordered) {
        std::string key;
        for (const auto& col : columns_) {
            if (row.find(col) == row.end()) {
                throw std::invalid_argument("Column '" + col + "' not found in row for index.");
            }
            key += row.at(col).to_string() + "|";
        }
        unordered_map_[key].push_back(row_id);
    }
    else if (type_ == IndexType::Ordered) {
        if (columns_.size() != 1) {
            throw std::invalid_argument("Ordered index can only be created on a single column.");
        }
        const std::string& col = columns_[0];
        if (row.find(col) == row.end()) {
            throw std::invalid_argument("Column '" + col + "' not found in row for index.");
        }
        ordered_map_[row.at(col).to_string()] = row_id;
    }
}

void Index::remove_row(RowID row_id, const std::unordered_map<std::string, Value>& row) {
    if (type_ == IndexType::Unordered) {
        std::string key;
        for (const auto& col : columns_) {
            if (row.find(col) == row.end()) {
                throw std::invalid_argument("Column '" + col + "' not found in row for index.");
            }
            key += row.at(col).to_string() + "|";
        }
        auto it = unordered_map_.find(key);
        if (it != unordered_map_.end()) {
            it->second.erase(std::remove(it->second.begin(), it->second.end(), row_id), it->second.end());
            if (it->second.empty()) {
                unordered_map_.erase(it);
            }
        }
    }
    else if (type_ == IndexType::Ordered) {
        if (columns_.size() != 1) {
            throw std::invalid_argument("Ordered index can only be created on a single column.");
        }
        const std::string& col = columns_[0];
        auto it = ordered_map_.find(row.at(col).to_string());
        if (it != ordered_map_.end() && it->second == row_id) {
            ordered_map_.erase(it);
        }
    }
}

std::vector<RowID> Index::search_unordered(const std::unordered_map<std::string, Value>& condition) const {
    std::vector<RowID> result;
    std::string key;
    for (const auto& col : columns_) {
        auto it = condition.find(col);
        if (it == condition.end()) {
            return result;
        }
        key += it->second.to_string() + "|";
    }
    auto it = unordered_map_.find(key);
    if (it != unordered_map_.end()) {
        result = it->second;
    }
    return result;
}

std::vector<RowID> Index::search_ordered(const std::string& column,
                                        const std::optional<Value>& lower,
                                        bool lower_inclusive,
                                        const std::optional<Value>& upper,
                                        bool upper_inclusive) const {
    std::vector<RowID> result;
    if (columns_.size() != 1 || columns_[0] != column) {
        return result;
    }

    auto it_lower = lower.has_value() ? (lower_inclusive ? ordered_map_.lower_bound(lower->to_string()) 
                                                       : ordered_map_.upper_bound(lower->to_string()))
                                       : ordered_map_.begin();
    auto it_upper = upper.has_value() ? (upper_inclusive ? ordered_map_.upper_bound(upper->to_string()) 
                                                       : ordered_map_.lower_bound(upper->to_string()))
                                       : ordered_map_.end();

    for (auto it = it_lower; it != it_upper; ++it) {
        result.push_back(it->second);
    }

    return result;
}

} // namespace core
} // namespace memdb
```
Lexer.cpp
```
#include "memdb/core/Lexer.h"

#include "memdb/core/exceptions/TypeMismatchException.h"

#include <limits>
#include <numeric>
#include <iostream>

namespace memdb {
namespace core {

Lexer::Lexer(const std::string& input) : input_(input), pos_(0) {}

char Lexer::peek() const {
    if (pos_ >= input_.size()) return '\0';
    return input_[pos_];
}

char Lexer::get_char() {
    if (pos_ >= input_.size()) return '\0';
    return input_[pos_++];
}

void Lexer::skip_whitespace() {
    while (std::isspace(peek())) {
        get_char();
    }
}

Token Lexer::get_next_token() {
    skip_whitespace();

    char current = peek();

    if (current == '\0') {
        return Token{TokenType::EndOfInput, ""};
    }

    if (std::isalpha(current) || current == '_') {
        return identifier();
    }

    if (current == '0' && (input_.size() > pos_ + 1) && (input_[pos_ + 1] == 'x' || input_[pos_ + 1] == 'X')) {
        return bytes_literal();
    }

    if (std::isdigit(current) || 
        ((current == '-' || current == '+') && 
         (pos_ + 1 < input_.size()) && 
         std::isdigit(input_[pos_ + 1]))) {
        Token tok = number();
        return tok;
    }

    if (current == '"') {
        return string_literal();
    }

    std::string var_name;  // for Length operator

    switch (current) {
        case ',': get_char(); return Token{TokenType::Comma, ","};
        case '(': get_char(); return Token{TokenType::LeftParen, "("};
        case ')': get_char(); return Token{TokenType::RightParen, ")"};
        case '+': get_char(); return Token{TokenType::Operator, "+"};
        case '-': get_char(); return Token{TokenType::Operator, "-"};
        case '*': get_char(); return Token{TokenType::Operator, "*"};
        case '/': get_char(); return Token{TokenType::Operator, "/"};
        case '%': get_char(); return Token{TokenType::Operator, "%"};
        case '<':
            get_char();
            if (peek() == '=') {
                get_char();
                return Token{TokenType::Operator, "<="};
            }
            return Token{TokenType::Operator, "<"};
        case '>':
            get_char();
            if (peek() == '=') {
                get_char();
                return Token{TokenType::Operator, ">="};
            }
            return Token{TokenType::Operator, ">"};
        case '=':
            get_char();
            if (peek() == '=') {
                get_char();
                return Token{TokenType::Operator, "=="};
            }
            return Token{TokenType::Operator, "="};
        case '!':
            get_char();
            if (peek() == '=') {
                get_char();
                return Token{TokenType::Operator, "!="};
            }
            return Token{TokenType::Operator, "!"};
        case '&':
            get_char();
            if (peek() == '&') {
                get_char();
                return Token{TokenType::Operator, "&&"};
            }
            throw exceptions::TypeMismatchException("Invalid character after '&'");
        case '|':
            get_char();
            if (peek() == '|') {
                get_char();
                return Token{TokenType::Operator, "||"};
            }

            while (std::isalnum(peek()) || peek() == '_') {
                var_name += get_char();
            }

            if (peek() == '|') {
                get_char();
                return Token{TokenType::Length, var_name};
            }
            else {
                throw exceptions::TypeMismatchException("Invalid operator after '|': expected '|'");
            }
            return Token{TokenType::Operator, "|"};
        case '^':
            get_char();
            if (peek() == '^') {
                get_char();
                return Token{TokenType::Operator, "^^"};
            }
            throw exceptions::TypeMismatchException("Invalid character after '^'");
        default:
            throw exceptions::TypeMismatchException(std::string("Unknown character: ") + current);
    }
}

Token Lexer::identifier() {
    std::string result;
    while (std::isalnum(peek()) || peek() == '_' || peek() == '.') { // Include dot
        result += get_char();
    }

    if (result == "true" || result == "false") {
        return Token{TokenType::BoolLiteral, result};
    }

    return Token{TokenType::Identifier, result};
}

Token Lexer::number() {
    std::string num_str;
    if (peek() == '-' || peek() == '+') {
        num_str += get_char();
    }

    while (std::isdigit(peek())) {
        num_str += get_char();
    }

    return Token{TokenType::IntLiteral, num_str};
}

Token Lexer::string_literal() {
    std::string str;
    get_char(); // consume opening ".
    while (peek() != '"' && peek() != '\0') {
        if (peek() == '\\') { 
            // Handle escape sequences
            get_char(); // consume '\\'
            char esc = get_char();
            switch (esc) {
                case 'n': str += '\n'; break;
                case 't': str += '\t'; break;
                case 'r': str += '\r'; break;
                case '\\': str += '\\'; break;
                case '"': str += '"'; break;
                default: str += esc; break;
            }
        } else {
            str += get_char();
        }
    }
    if (peek() == '\0') {
        throw exceptions::TypeMismatchException("Unterminated string literal.");
    }
    get_char(); // consume closing "
    return Token{TokenType::StringLiteral, str};
}

Token Lexer::bytes_literal() {
    std::string bytes_str;
    bytes_str += get_char(); // consume '0'
    bytes_str += get_char(); // consume 'x' or 'X'

    while (std::isxdigit(peek())) {
        bytes_str += get_char();
    }

    return Token{TokenType::BytesLiteral, bytes_str};
}

} // namespace core
} // namespace memdb
```
QueryExecutor.cpp
```
#include "memdb/core/Database.h"
#include "memdb/core/QueryExecutor.h"
#include "memdb/core/ExpressionParser.h"

#include "memdb/core/exceptions/DatabaseException.h"
#include "memdb/core/exceptions/TypeMismatchException.h"
#include "memdb/core/structs/ColumnInfo.h"

#include <algorithm>
#include <iostream>
#include <regex>

namespace memdb {
namespace core {

using json = nlohmann::json;

QueryResult QueryExecutor::execute(const ParsedQuery& parsed_query, Database& db) {
    switch (parsed_query.type) {
        case ParsedQuery::QueryType::CreateTable:
            try {
                db.create_table(parsed_query.table_name, parsed_query.columns);
                return QueryResult();
            }
            catch (const exceptions::TypeMismatchException& e) {
                return QueryResult(e.what());
            }
            catch (const exceptions::DatabaseException& e) {
                return QueryResult(e.what());
            }
            catch (const std::exception& e) {
                return QueryResult(e.what());
            }
            catch (...) {
                return QueryResult("Unknown error during query execution.");
            }
            break;
        
        case ParsedQuery::QueryType::Insert:
            try {
                std::shared_ptr<Table> table = db.get_table(parsed_query.table_name);
                core::RowID new_row_id = table->insert_row(*(parsed_query.insert_values));
                std::vector<std::vector<std::optional<Value>>> data = { { Value(static_cast<int32_t>(new_row_id)) } };
                return QueryResult(data);
            }
            catch (const exceptions::DatabaseException& e) {
                return QueryResult(e.what());
            }
            break;
        
        case ParsedQuery::QueryType::Select:
            return execute_select(parsed_query, db);
            break;
        
        case ParsedQuery::QueryType::Update:
            return execute_update(parsed_query, db);
            break;
        
        case ParsedQuery::QueryType::Delete:
            return execute_delete(parsed_query, db);
            break;
        
        case ParsedQuery::QueryType::CreateIndex:
            return execute_create_index(parsed_query, db);
            break;
        
        default:
            return QueryResult("Unsupported query type.");
    }
}

QueryResult QueryExecutor::execute_select(const ParsedQuery& pq, Database& db) {
    try {
        std::vector<std::vector<std::optional<Value>>> results;
        std::vector<ColumnInfo> result_columns;

        if (!pq.joins.empty()) {
            auto table1 = db.get_table(pq.table_name);
            auto table2 = db.get_table(pq.joins[0].table_name);

            const auto& columns1 = table1->get_columns();
            const auto& columns2 = table2->get_columns();

            std::vector<ColumnInfo> aliased_columns1;
            for (const auto& col : columns1) {
                std::string aliased_name = pq.table_name + "." + col.get_name();
                aliased_columns1.emplace_back(ColumnInfo(aliased_name, col.get_type()));
                result_columns.emplace_back(ColumnInfo(aliased_name, col.get_type()));
            }

            std::vector<ColumnInfo> aliased_columns2;
            for (const auto& col : columns2) {
                std::string aliased_name = pq.joins[0].table_name + "." + col.get_name();
                aliased_columns2.emplace_back(ColumnInfo(aliased_name, col.get_type()));
                result_columns.emplace_back(ColumnInfo(aliased_name, col.get_type()));
            }

            for (const auto& [row_id1, row1] : table1->get_all_rows()) {
                std::unordered_map<std::string, Value> row_map;
                for (size_t i = 0; i < columns1.size(); ++i) {
                    if (row1.get_values()[i].has_value()) {
                        std::string col_name = aliased_columns1[i].get_name();
                        row_map[pq.table_name + "." + col_name] = *(row1.get_values()[i]);
                    }
                }

                for (const auto& [row_id2, row2] : table2->get_all_rows()) {
                    std::unordered_map<std::string, Value> combined_row_map = row_map; 
                    for (size_t i = 0; i < columns2.size(); ++i) {
                        if (row2.get_values()[i].has_value()) {
                            std::string col_name = aliased_columns2[i].get_name();
                            combined_row_map[pq.joins[0].table_name + "." + col_name] = *(row2.get_values()[i]);
                        }
                    }

                    Value join_cond_value = pq.joins[0].join_condition->evaluate(combined_row_map);
                    if (join_cond_value.get_type() != Type::Bool) {
                        throw std::invalid_argument("JOIN condition does not evaluate to a boolean.");
                    }
                    if (join_cond_value.get_bool()) {
                        bool where_match = true;
                        if (pq.where_clause) {
                            Value where_cond = pq.where_clause->evaluate(combined_row_map);
                            if (where_cond.get_type() != Type::Bool) {
                                throw std::invalid_argument("WHERE clause does not evaluate to a boolean.");
                            }
                            where_match = where_cond.get_bool();
                        }
                        if (where_match) {
                            std::vector<std::optional<Value>> selected_values;
                            for (const auto& select_item : pq.select_items) {
                                try {
                                    Value val = select_item.expression->evaluate(row_map);
                                    selected_values.push_back(val);
                                } catch (const std::exception& e) {
                                    return QueryResult("Error evaluating expression in SELECT clause: " + std::string(e.what()));
                                }
                            }
                            results.push_back(selected_values);
                        }
                    }
                }
            }

            return QueryResult(results, result_columns);
        } else {
            auto table = db.get_table(pq.table_name);
            const auto& columns = table->get_columns();

            std::vector<std::vector<std::optional<Value>>> results;

            for (const auto& select_item : pq.select_items) {

                DataType expr_type = select_item.expression->get_type(); 

                result_columns.emplace_back(ColumnInfo(select_item.alias, expr_type));
            }

            for (const auto& [row_id, row] : table->get_all_rows()) {
                std::unordered_map<std::string, Value> row_map;
                for (size_t i = 0; i < columns.size(); ++i) {
                    if (row.get_values()[i].has_value()) {
                        row_map[columns[i].get_name()] = *(row.get_values()[i]);
                    }
                }

                bool match = true;
                if (pq.where_clause) {
                    Value cond = pq.where_clause->evaluate(row_map);
                    if (cond.get_type() != Type::Bool) {
                        throw std::invalid_argument("WHERE clause does not evaluate to a boolean.");
                    }
                    match = cond.get_bool();
                }

                if (match) {
                    std::vector<std::optional<Value>> selected_values;
                    for (const auto& select_item : pq.select_items) {
                        try {
                            Value val = select_item.expression->evaluate(row_map);
                            selected_values.push_back(val);
                        } catch (const std::exception& e) {
                            return QueryResult("Error evaluating expression in SELECT clause: " + std::string(e.what()));
                        }
                    }
                    results.push_back(selected_values);
                }
            }

            return QueryResult(results, result_columns);
        }
    } catch (const exceptions::DatabaseException& e) {
        return QueryResult(e.what());
    } catch (const std::exception& e) {
        return QueryResult(e.what());
    }
}

QueryResult QueryExecutor::execute_update(const ParsedQuery& pq, Database& db) {
    try {
        std::shared_ptr<Table> table = db.get_table(pq.table_name);
        const auto& columns = table->get_columns();

        size_t updated_count = 0;

        for (auto& [row_id, row] : table->get_all_rows()) {
            std::unordered_map<std::string, Value> row_map;
            for (size_t i = 0; i < columns.size(); ++i) {
                if (row.get_values()[i].has_value()) {
                    row_map[columns[i].get_name()] = *(row.get_values()[i]);
                }
            }

            bool match = true;
            if (pq.update_where_clause) {
                Value cond = pq.update_where_clause->evaluate(row_map);
                if (cond.get_type() != Type::Bool) {
                    throw std::invalid_argument("WHERE clause does not evaluate to a boolean.");
                }
                match = cond.get_bool();
            }

            if (match) {
                for (const auto& [col_name, expr] : pq.update_assignments) {
                    size_t col_index = table->get_column_index(col_name);
                    const Column& column = columns[col_index];
                    Value new_val = expr->evaluate(row_map);

                    if (new_val.get_type() != column.get_type().get_type()) {
                        throw exceptions::TypeMismatchException("Type mismatch in SET assignment for column '" + col_name + "'.");
                    }

                    row.set_value(col_index, new_val);
                    row_map[col_name] = new_val;
                }
                updated_count++;
            }
        }

        std::vector<std::vector<std::optional<Value>>> data = { { Value(static_cast<int32_t>(updated_count)) } };
        return QueryResult(data);
    }
    catch (const exceptions::DatabaseException& e) {
        return QueryResult(e.what());
    }
}

QueryResult QueryExecutor::execute_delete(const ParsedQuery& pq, Database& db) {
    try {
        std::shared_ptr<Table> table = db.get_table(pq.table_name);
        const auto& columns = table->get_columns();

        std::vector<core::RowID> rows_to_delete;

        for (const auto& [row_id, row] : table->get_all_rows()) {
            std::unordered_map<std::string, Value> row_map;
            for (size_t i = 0; i < columns.size(); ++i) {
                if (row.get_values()[i].has_value()) {
                    row_map[columns[i].get_name()] = *(row.get_values()[i]);
                }
            }

            bool match = true;
            if (pq.delete_where_clause) {
                Value cond = pq.delete_where_clause->evaluate(row_map);
                if (cond.get_type() != Type::Bool) {
                    throw std::invalid_argument("WHERE clause does not evaluate to a boolean.");
                }
                match = cond.get_bool();
            }

            if (match) {
                rows_to_delete.emplace_back(row_id);
            }
        }

        for (const auto& row_id : rows_to_delete) {
            table->delete_row(row_id);
        }

        std::vector<std::vector<std::optional<Value>>> data = { { Value(static_cast<int32_t>(rows_to_delete.size())) } };
        return QueryResult(data);
    }
    catch (const exceptions::DatabaseException& e) {
        return QueryResult(e.what());
    }
}

QueryResult QueryExecutor::execute_create_index(const ParsedQuery& pq, Database& db) {
    try {
        db.create_index(pq.table_name, pq.index_type, pq.index_columns);
        return QueryResult();
    }
    catch (const exceptions::DatabaseException& e) {
        return QueryResult(e.what());
    }
    catch (const std::exception& e) {
        return QueryResult(e.what());
    }
}

} // namespace core
} // namespace memdb
```
QueryParser.cpp
```
#include "memdb/core/QueryParser.h"
#include "memdb/core/Table.h"
#include "memdb/core/Database.h"
#include "memdb/core/ExpressionParser.h"

#include "memdb/core/exceptions/DatabaseException.h"

#include <sstream>
#include <algorithm>
#include <cctype>
#include <limits>
#include <stdexcept>
#include <regex>
#include <unordered_set>

namespace memdb {
namespace core {

bool QueryParser::validate_query(const std::string& query) {
    std::stack<char> s;
    for (char ch : query) {
        if (ch == '(' || ch == '{') {
            s.push(ch);
        } else if (ch == ')' || ch == '}') {
            if (s.empty()) {
                return false;
            }
            char open = s.top();
            s.pop();
            if ((ch == ')' && open != '(') || (ch == '}' && open != '{')) {
                return false;
            }
        }
    }
    return s.empty();
}

const std::unordered_set<std::string> reservedKeywords = {
    "create", "table", "insert", "update", "delete", "join", "where", "int32", "string", "bytes", "bool", "key", "unique", "autoincrement",  "index", "unordered", "ordered", "on", "select", "from", "values", "as"
};

bool isValidIdentifier(const std::string& identifier) {
    std::regex valid_identifier_regex("^[a-zA-Z][a-zA-Z0-9_]*$");
    bool regex_match = std::regex_match(identifier, valid_identifier_regex);
    if (!regex_match) {
        return false;
    }
    
    std::string lower_identifier = identifier;
    std::transform(lower_identifier.begin(), lower_identifier.end(), lower_identifier.begin(), ::tolower);
    return reservedKeywords.find(lower_identifier) == reservedKeywords.end();
}

void QueryParser::set_database(Database* db) {
    db_ = db;
}

Value parse_value(TokenType token_type, const std::string& value_str, size_t size = 0) {
    switch (token_type) {
        case TokenType::StringLiteral:
            if (size > 0 && value_str.size() > size) {
                throw std::invalid_argument("String value exceeds defined size of " + 
                    std::to_string(size));
            }
            
            return Value(value_str);

        case TokenType::BytesLiteral: {
            std::string hex_str = value_str.substr(2);
            if (hex_str.size() % 2 != 0) {
                throw std::invalid_argument("Invalid hex string for bytes.");
            }
            size_t bytes_size = hex_str.size() / 2;
            if (bytes_size > size) {
                throw std::invalid_argument("Bytes value exceeds defined size of " + 
                    std::to_string(size));
            }
            std::vector<uint8_t> bytes;
            bytes.reserve(bytes_size);
            for (size_t i = 0; i < hex_str.size(); i += 2) {
                std::string byte_str = hex_str.substr(i, 2);
                uint8_t byte = static_cast<uint8_t>(std::stoul(byte_str, nullptr, 16));
                bytes.push_back(byte);
            }
            return Value(bytes);
        }

        case TokenType::BoolLiteral:
            return Value(value_str == "true");

        case TokenType::IntLiteral:
            try {
                int32_t int_val = std::stoi(value_str);
                return Value(int_val);
            } catch (const std::exception&) {
                throw std::invalid_argument("Invalid integer value: " + value_str);
            }

        default:
            throw std::invalid_argument("Invalid value: " + value_str);
    }
}

std::vector<std::optional<Value>> parse_values(const std::string& values_str, const std::vector<Column>& columns) {
    std::vector<std::optional<Value>> values(columns.size(), std::nullopt);
    Lexer lexer(values_str);
    Token token = lexer.get_next_token();

    bool named_format = false;
    size_t peek_pos = values_str.find('=');
    if (peek_pos != std::string::npos) {
        named_format = true;
    }

    if (named_format) {
        std::unordered_set<std::string> processed_columns;
        while (token.type != TokenType::EndOfInput) {
            std::string column_name;
            while (token.type != TokenType::EndOfInput && token.type != TokenType::Operator && token.value != "=") {
                if (token.type == TokenType::Identifier) {
                    column_name = token.value;
                }
                token = lexer.get_next_token();
            }
            
            if (token.type != TokenType::Operator || token.value != "=") {
                throw std::invalid_argument("Expected '=' after column name");
            }
            token = lexer.get_next_token();

            if (processed_columns.find(column_name) != processed_columns.end()) {
                throw std::invalid_argument("Duplicate column name: " + column_name);
            }
            processed_columns.insert(column_name);
            
            size_t col_idx = 0;
            bool found = false;
            for (size_t i = 0; i < columns.size(); i++) {
                if (columns[i].get_name() == column_name) {
                    col_idx = i;
                    found = true;
                    break;
                }
            }
            if (!found) {
                throw std::invalid_argument("Column not found: " + column_name);
            }
            
            if (token.type == TokenType::StringLiteral || token.type == TokenType::BytesLiteral ||
                token.type == TokenType::IntLiteral || token.type == TokenType::BoolLiteral) {
                const Column& col = columns[col_idx];
                size_t size = (col.get_type().get_type() == Type::String || 
                             col.get_type().get_type() == Type::Bytes) ? col.get_type().get_size() : 0;
                values[col_idx] = parse_value(token.type, token.value, size);
            }
            
            token = lexer.get_next_token();
            if (token.type == TokenType::Comma) {
                token = lexer.get_next_token();
            }
        }

        for (size_t i = 0; i < columns.size(); ++i) {
            if (!values[i].has_value()) {
                if (columns[i].has_attribute(ColumnAttribute::AutoIncrement)) {
                    continue;
                }
                if (columns[i].get_default_value().has_value()) {
                    values[i] = columns[i].get_default_value();
                } else {
                    throw std::invalid_argument("Missing value for column: " + columns[i].get_name());
                }
            }
        }
    } else {
        size_t column_index = 0;
        while (token.type != TokenType::EndOfInput) {
            if (token.type == TokenType::Comma) {
                values[column_index] = std::nullopt;
                token = lexer.get_next_token();
                column_index++;
                continue;
            }

            if (column_index >= columns.size()) {
                throw std::invalid_argument("Too many values for table columns");
            }

            const Column& current_column = columns[column_index];
            const DataType& dtype = current_column.get_type();
            size_t size = 0;

            if (dtype.get_type() == Type::String || dtype.get_type() == Type::Bytes) {
                size = dtype.get_size();
            }

            if (token.type == TokenType::StringLiteral || token.type == TokenType::BytesLiteral ||
                token.type == TokenType::IntLiteral || token.type == TokenType::BoolLiteral) {
                if (!token.value.empty()) {
                    values[column_index] = parse_value(token.type, token.value, size);
                } else {
                    values[column_index] = std::nullopt;
                }
            } else {
                throw std::invalid_argument("Invalid value in INSERT statement: " + token.value);
            }

            token = lexer.get_next_token();
            if (token.type == TokenType::Comma) {
                token = lexer.get_next_token();
            }
            column_index++;
        }

        while (column_index < columns.size()) {
            if (columns[column_index].has_attribute(ColumnAttribute::AutoIncrement)) {
                column_index++;
                continue;
            }
            if (columns[column_index].get_default_value().has_value()) {
                values[column_index] = columns[column_index].get_default_value();
            } else {
                throw std::invalid_argument("Missing value for column: " + columns[column_index].get_name());
            }
            column_index++;
        }
    }

    return values;
}

ParsedQuery QueryParser::parse(const std::string& query) {
    bool valid = QueryParser::validate_query(query);
    if (!valid) {
        throw std::invalid_argument("Unbalanced parentheses or braces in query.");
    }
    std::string trimmed_query = trim(query);

    ParsedQuery pq;
    std::istringstream iss(trimmed_query);
    std::string command;
    iss >> command;

    std::transform(command.begin(), command.end(), command.begin(), ::tolower);

    if (command == "create") {
        std::string index_type_or_subcommand;
        iss >> index_type_or_subcommand;
        std::transform(index_type_or_subcommand.begin(), index_type_or_subcommand.end(), index_type_or_subcommand.begin(), ::tolower);
        if (index_type_or_subcommand == "table") {
            pq.type = ParsedQuery::QueryType::CreateTable;

            iss >> std::ws;
            if (iss.peek() == '(') {
                throw std::invalid_argument("Table name cannot be empty.");
            }

            iss >> pq.table_name;

            if (!isValidIdentifier(pq.table_name)) {
                throw std::invalid_argument("Invalid table name: " + pq.table_name);
            }
            if (reservedKeywords.count(pq.table_name)) {
                throw std::invalid_argument("Reserved keyword used as table name: " + pq.table_name);
            }

            char c;
            iss >> c;
            if (c != '(') {
                throw std::invalid_argument("Expected '(' after table name.");
            }

            std::string columns_def;
            std::getline(iss, columns_def, ';');
            columns_def = columns_def.substr(0, columns_def.size() - 1);

            std::vector<std::string> column_defs = split_columns(columns_def);

            for (const auto& col_def : column_defs) {
                Column column = parse_column_definition(col_def);
                if (!isValidIdentifier(column.get_name())) {
                    throw std::invalid_argument("Invalid column name: " + column.get_name());
                }
                pq.columns.push_back(column);
            }
        }
        else if (index_type_or_subcommand == "ordered" || index_type_or_subcommand == "unordered") {
            pq.type = ParsedQuery::QueryType::CreateIndex;
            pq.index_type = index_type_or_subcommand;

            std::string index_keyword;
            iss >> index_keyword;
            std::transform(index_keyword.begin(), index_keyword.end(), index_keyword.begin(), ::tolower);
            if (index_keyword != "index") {
                throw std::invalid_argument("Expected 'index' after index type.");
            }

            std::string on_word;
            iss >> on_word;
            std::transform(on_word.begin(), on_word.end(), on_word.begin(), ::tolower);
            if (on_word != "on") {
                throw std::invalid_argument("Expected 'on' after 'create <index_type> index'.");
            }

            iss >> pq.table_name;

            if (!isValidIdentifier(pq.table_name)) {
                throw std::invalid_argument("Invalid table name: " + pq.table_name);
            }
            if (reservedKeywords.count(pq.table_name)) {
                throw std::invalid_argument("Reserved keyword used as table name: " + pq.table_name);
            }

            std::string by_word;
            iss >> by_word;
            std::transform(by_word.begin(), by_word.end(), by_word.begin(), ::tolower);
            if (by_word != "by") {
                throw std::invalid_argument("Expected 'by' after table name in 'create index'.");
            }

            std::string columns_str;
            std::getline(iss, columns_str);
            size_t first = columns_str.find_first_not_of(" \t\r\n");
            size_t last = columns_str.find_last_not_of(" \t\r\n");
            if (first != std::string::npos && last != std::string::npos) {
                columns_str = columns_str.substr(first, last - first + 1);
            }

            std::stringstream columns_stream(columns_str);
            std::string col;
            while (std::getline(columns_stream, col, ',')) {
                col.erase(col.begin(), std::find_if(col.begin(), col.end(),
                            [](unsigned char ch) { return !std::isspace(ch); }));
                col.erase(std::find_if(col.rbegin(), col.rend(),
                            [](unsigned char ch) { return !std::isspace(ch); }).base(), col.end());
                if (!isValidIdentifier(col)) {
                    throw std::invalid_argument("Invalid column name: " + col);
                }
                pq.index_columns.push_back(col);
            }
        }
        else {
            throw std::invalid_argument("Unknown CREATE subcommand: " + index_type_or_subcommand);
        }
    }
    else if (command == "insert") {
        // insert (,"vasya", Oxdeadbeefdeadbeef) to users
        // insert (login = "vasya", password_hash = Oxdeadbeefdeadbeef) to users
        pq.type = ParsedQuery::QueryType::Insert;
        pq.insert_values = std::vector<std::optional<Value>>();

        std::regex insert_regex(R"(^insert\s*\(([\s\S]*)\)\s*to\s+(\w+);$)", std::regex::icase);
        std::smatch matches;
        if (std::regex_match(trimmed_query, matches, insert_regex)) {
            std::string values_str = matches[1];
            std::string table_name = matches[2];

            if (!isValidIdentifier(table_name)) {
                throw std::invalid_argument("Invalid table name: " + table_name);
            }
            if (reservedKeywords.count(table_name)) {
                throw std::invalid_argument("Reserved keyword used as table name: " + table_name);
            }

            pq.table_name = table_name;

            if (!db_) {
                throw std::runtime_error("Database reference is not set in QueryParser.");
            }

            std::shared_ptr<memdb::core::Table> table;
            try {
                table = db_->get_table(table_name);
                const auto& columns = table->get_columns();
                pq.insert_values = parse_values(values_str, columns);
            } catch (exceptions::TableNotFoundException& e) {
                throw std::invalid_argument("Table does not exist: " + table_name);
            }
        }
        else {
            throw std::invalid_argument("Invalid INSERT syntax.");
        }
    }
    else if (command == "select") {
        pq.type = ParsedQuery::QueryType::Select;

        std::string rest_of_query;
        std::getline(iss, rest_of_query);
        rest_of_query = command + " " + rest_of_query;

        std::regex select_regex(R"(select\s+(.+?)\s+from\s+(\w+)(?:\s+join\s+(\w+)\s+on\s+(.+?))?(?:\s+where\s+(.+))?$)", std::regex::icase);        
        std::smatch matches;
        if (std::regex_match(rest_of_query, matches, select_regex)) {
            std::string columns_str = matches[1];
            std::string table_name = matches[2];

            if (!isValidIdentifier(table_name)) {
                throw std::invalid_argument("Invalid table name: " + table_name);
            }
            if (reservedKeywords.count(table_name)) {
                throw std::invalid_argument("Reserved keyword used as table name: " + table_name);
            }

            pq.table_name = table_name;

            std::vector<std::string> column_defs = split_columns(columns_str);

            std::regex select_col_regex(R"(^([^\s,]+(?:\s+[^\s,]+)*)(?:\s+as\s+(\w+))?$)", std::regex::icase);

            for (const auto& col_def : column_defs) {
                std::smatch col_matches;
                if (!std::regex_match(col_def, col_matches, select_col_regex)) {
                    throw std::invalid_argument("Invalid SELECT column definition: " + col_def);
                }

                std::string expr_str = col_matches[1];
                std::string alias = col_matches[2].matched ? col_matches[2].str() : "";

                expr_str = trim(expr_str);
                alias = trim(alias.empty() ? expr_str : alias); 

                ExpressionParser expr_parser(expr_str);
                auto expression = expr_parser.parse_expression();

                ParsedQuery::SelectItem select_col;
                select_col.expression = std::move(expression);
                select_col.alias = alias;

                pq.select_items.emplace_back(std::move(select_col));
            }

            if (matches[3].matched) {
                ParsedQuery::JoinInfo join_info;
                join_info.table_name = matches[3].str();
                std::string join_condition_str = matches[4].str();

                ExpressionParser expr_parser(join_condition_str);
                join_info.join_condition = expr_parser.parse_expression();

                pq.joins.push_back(std::move(join_info));
            }

            if (matches[5].matched) {
                std::string where_clause_str = matches[5].str();
                ExpressionParser expr_parser(where_clause_str);
                pq.where_clause = expr_parser.parse_expression();
            }
        } else {
            throw std::invalid_argument("Invalid SELECT syntax.");
        }
    }
    else if (command == "update") {
        pq.type = ParsedQuery::QueryType::Update;
        std::string table_name;
        iss >> table_name;
        pq.table_name = table_name;

        std::string set_word;
        iss >> set_word;
        std::transform(set_word.begin(), set_word.end(), set_word.begin(), ::tolower);
        if (set_word != "set") {
            throw std::invalid_argument("Expected 'set' after table name in UPDATE.");
        }

        std::string assignments_str;
        std::getline(iss, assignments_str, 'w'); 

        std::string where_part;
        std::getline(iss, where_part);
        size_t where_pos = assignments_str.find("where");
        if (where_pos != std::string::npos) {
            assignments_str = assignments_str.substr(0, where_pos);
        }

        std::stringstream assign_stream(assignments_str);
        std::string assign;
        while (std::getline(assign_stream, assign, ',')) {
            size_t eq_pos = assign.find('=');
            if (eq_pos == std::string::npos) {
                throw std::invalid_argument("Invalid assignment in UPDATE.");
            }
            std::string col_name = assign.substr(0, eq_pos);
            std::string expr_str = assign.substr(eq_pos + 1);

            if (!isValidIdentifier(col_name)) {
                throw std::invalid_argument("Invalid column name: " + col_name);
            }
            if (reservedKeywords.count(col_name)) {
                throw std::invalid_argument("Reserved keyword used as column name: " + pq.table_name);
            }

            size_t first = col_name.find_first_not_of(" \t\r\n");
            size_t last = col_name.find_last_not_of(" \t\r\n");
            if (first != std::string::npos && last != std::string::npos) {
                col_name = col_name.substr(first, last - first + 1);
            }

            first = expr_str.find_first_not_of(" \t\r\n");
            last = expr_str.find_last_not_of(" \t\r\n");
            if (first != std::string::npos && last != std::string::npos) {
                expr_str = expr_str.substr(first, last - first + 1);
            }

            ExpressionParser expr_parser(expr_str);
            pq.update_assignments[col_name] = expr_parser.parse_expression();
        }

        if (where_pos != std::string::npos) {
            std::string condition_str = assignments_str.substr(where_pos + 5); // 5 symbols 'where'
            size_t first = condition_str.find_first_not_of(" \t\r\n");
            size_t last = condition_str.find_last_not_of(" \t\r\n");
            if (first != std::string::npos && last != std::string::npos) {
                condition_str = condition_str.substr(first, last - first + 1);
            }
            ExpressionParser expr_parser(condition_str);
            pq.update_where_clause = expr_parser.parse_expression();
        }
    }
    else if (command == "delete") {
        pq.type = ParsedQuery::QueryType::Delete;
        std::string from_word;
        iss >> from_word;
        std::transform(from_word.begin(), from_word.end(), from_word.begin(), ::tolower);
        if (from_word != "from") {
            throw std::invalid_argument("Expected 'from' after 'delete'.");
        }

        std::string table_name;
        iss >> table_name;
        pq.table_name = table_name;

        std::string where_word;
        iss >> where_word;
        std::transform(where_word.begin(), where_word.end(), where_word.begin(), ::tolower);
        if (where_word != "where") {
            throw std::invalid_argument("Expected 'where' in DELETE.");
        }

        std::string condition_str;
        std::getline(iss, condition_str);
        size_t first = condition_str.find_first_not_of(" \t\r\n");
        size_t last = condition_str.find_last_not_of(" \t\r\n");
        if (first != std::string::npos && last != std::string::npos) {
            condition_str = condition_str.substr(first, last - first + 1);
        }
        ExpressionParser expr_parser(condition_str);
        pq.delete_where_clause = expr_parser.parse_expression();
    }
    else {
        throw std::invalid_argument("Unknown command: " + command);
    }

    return pq;
}

Column QueryParser::parse_column_definition(const std::string& col_def) {
    std::vector<ColumnAttribute> attributes;
    std::optional<Value> default_value = std::nullopt;
    std::string col_name;
    DataType data_type(Type::Int32);

    size_t start = 0;
    if (col_def[start] == '{') {
        size_t end = col_def.find('}', start);
        if (end == std::string::npos) {
            throw std::invalid_argument("Expected '}' for column attributes.");
        }
        std::string attrs_str = col_def.substr(start + 1, end - start - 1);
        std::stringstream attrs_stream(attrs_str);
        std::string attr;
        while (std::getline(attrs_stream, attr, ',')) {
            attr.erase(attr.begin(), std::find_if(attr.begin(), attr.end(),
                        [](unsigned char ch) { return !std::isspace(ch); }));
            attr.erase(std::find_if(attr.rbegin(), attr.rend(),
                        [](unsigned char ch) { return !std::isspace(ch); }).base(), attr.end());
            
            std::transform(attr.begin(), attr.end(), attr.begin(), ::tolower);

            if (attr == "unique") {
                attributes.emplace_back(ColumnAttribute::Unique);
            }
            else if (attr == "autoincrement") {
                attributes.emplace_back(ColumnAttribute::AutoIncrement);
            }
            else if (attr == "key") {
                attributes.emplace_back(ColumnAttribute::Key);
            }
            else {
                throw std::invalid_argument("Unknown column attribute: " + attr);
            }
        }
        start = end + 1;
    }

    size_t colon_pos = col_def.find(':', start);
    if (colon_pos == std::string::npos) {
        throw std::invalid_argument("Expected ':' in column definition.");
    }

    std::string name_part = col_def.substr(start, colon_pos - start);
    name_part.erase(name_part.begin(), std::find_if(name_part.begin(), name_part.end(),
                    [](unsigned char ch) { return !std::isspace(ch); }));
    name_part.erase(std::find_if(name_part.rbegin(), name_part.rend(),
                    [](unsigned char ch) { return !std::isspace(ch); }).base(), name_part.end());

    if (name_part.empty()) {
        throw std::invalid_argument("Column name is empty.");
    }
    col_name = name_part;

    size_t eq_pos = col_def.find('=', colon_pos + 1);
    std::string type_str;
    if (eq_pos != std::string::npos) {
        type_str = col_def.substr(colon_pos + 1, eq_pos - colon_pos - 1);
        type_str = trim(type_str);

        Type type;
        size_t size = 0;
        if (type_str.find("string[") != std::string::npos || type_str.find("bytes[") != std::string::npos) {
            size = std::stoul(type_str.substr(type_str.find('[') + 1,
                                        type_str.find(']') - type_str.find('[') - 1));
        }

        std::string default_val_str = col_def.substr(eq_pos + 1);
        default_val_str = trim(default_val_str);

        Lexer lexer(default_val_str);
        Token token = lexer.get_next_token();

        if (token.type == TokenType::EndOfInput) {
            throw std::invalid_argument("Invalid default value: " + default_val_str);
        }

        default_value = parse_value(token.type, token.value, size);
    } else {
        type_str = col_def.substr(colon_pos + 1);
        type_str = trim(type_str);
    }

    std::transform(type_str.begin(), type_str.end(), type_str.begin(), ::tolower);

    Type type;
    size_t size = 0;
    if (type_str.find("int32") != std::string::npos) {
        type = Type::Int32;
    }
    else if (type_str.find("string") != std::string::npos) {
        type = Type::String;
        size = std::stoul(type_str.substr(type_str.find('[') + 1,
                                           type_str.find(']') - type_str.find('[') - 1));
    }
    else if (type_str.find("bytes") != std::string::npos) {
        type = Type::Bytes;
        size = std::stoul(type_str.substr(type_str.find('[') + 1,
                                           type_str.find(']') - type_str.find('[') - 1));
    }
    else if (type_str.find("bool") != std::string::npos) {
        type = Type::Bool;
    }
    else {
        throw std::invalid_argument("Unknown column type: " + type_str);
    }

    if (type == Type::String || type == Type::Bytes) {
        data_type = DataType(type, size);
    }
    else {
        data_type = DataType(type);
    }

    return Column(col_name, data_type, attributes, default_value);
}

std::vector<std::string> QueryParser::split_columns(const std::string& columns_def) {
    std::vector<std::string> columns;
    int brace_level = 0;
    int paren_level = 0;
    std::string current;
    
    for (char ch : columns_def) {
        if (ch == '{') {
            brace_level++;
            current += ch;
        }
        else if (ch == '}') {
            if (brace_level == 0) {
                throw std::invalid_argument("Unbalanced braces in column definitions.");
            }
            brace_level--;
            current += ch;
        }
        else if (ch == '(') {
            paren_level++;
            current += ch;
        }
        else if (ch == ')') {
            if (paren_level == 0) {
                throw std::invalid_argument("Unbalanced parantheses in column definitions.");
            }
            paren_level--;
            current += ch;
        }
        else if (ch == ',' && brace_level == 0 && paren_level == 0) {
            size_t first = current.find_first_not_of(" \t\r\n");
            size_t last = current.find_last_not_of(" \t\r\n");
            if (first != std::string::npos && last != std::string::npos) {
                columns.emplace_back(current.substr(first, last - first + 1));
            }
            current.clear();
        }
        else {
            current += ch;
        }
    }
    
    size_t first = current.find_first_not_of(" \t\r\n");
    size_t last = current.find_last_not_of(" \t\r\n");
    if (first != std::string::npos && last != std::string::npos) {
        columns.emplace_back(current.substr(first, last - first + 1));
    }

    if (brace_level != 0 || paren_level != 0) {
        throw std::invalid_argument("Unbalanced parentheses or braces in column definitions.");
    }
    
    return columns;
}

std::string QueryParser::trim(const std::string& s) {
    auto start = std::find_if_not(s.begin(), s.end(), [](unsigned char ch) {
        return std::isspace(ch);
    });
    auto end = std::find_if_not(s.rbegin(), s.rend(), [](unsigned char ch) {
        return std::isspace(ch);
    }).base();
    
    return (start < end ? std::string(start, end) : "");
}

} // namespace core
} // namespace memdb
```
QueryResult.cpp
```
#include "memdb/core/QueryResult.h"

#include <algorithm>
#include <iostream>
#include <iomanip>

namespace memdb {
namespace core {

void QueryResult::print(std::ostream& os) const {
    if (!success_) {
        os << "Error: " << error_message_ << "\n";
        return;
    }

    os << "Number of columns: " << columns_.size() << "\n";

    std::vector<size_t> col_widths;
    for (size_t i = 0; i < columns_.size(); ++i) {
        size_t name_length = columns_[i].get_name().length();
        size_t type_length = columns_[i].type.to_string().length();
        size_t max_width = std::max(name_length, type_length);
        
        for (const auto& row : data_) {
            if (i < row.size()) { 
                const auto& val = row[i];
                size_t val_length = val.has_value() ? val->to_string().length() : 4; // "NULL" имеет длину 4
                if (val_length > max_width) {
                    max_width = val_length;
                }
            }
        }
        col_widths.push_back(max_width + 2); 
    }

    auto print_separator = [&](const std::vector<size_t>& widths) {
        for (const auto& width : widths) {
            os << "+" << std::string(width + 2, '-');
        }
        os << "+\n";
    };

    print_separator(col_widths);

    os << "|";
    for (size_t i = 0; i < columns_.size(); ++i) {
        os << " " << std::left << std::setw(col_widths[i]) 
           << columns_[i].get_name() << " |";
    }
    os << "\n";

    os << "|";
    for (size_t i = 0; i < columns_.size(); ++i) {
        os << " " << std::left << std::setw(col_widths[i]) 
           << columns_[i].type.to_string() << " |";
    }
    os << "\n";

    print_separator(col_widths);

    for (const auto& row : data_) {
        os << "|";
        for (size_t i = 0; i < columns_.size(); ++i) {
            std::string value_str = "NULL";
            if (i < row.size() && row[i].has_value()) {
                value_str = row[i]->to_string();
            }
            if (value_str.length() > col_widths[i]) {
                value_str = value_str.substr(0, col_widths[i] - 3) + "...";
            }
            os << " " << std::left << std::setw(col_widths[i]) 
               << value_str << " |";
        }
        os << "\n";
    }

    print_separator(col_widths);
}

std::ostream& operator<<(std::ostream& os, const QueryResult& qr) {
    qr.print(os);
    return os;
}


QueryResultIterator QueryResult::begin() const {
    return QueryResultIterator(data_.cbegin(), columns_);
}

QueryResultIterator QueryResult::end() const {
    return QueryResultIterator(data_.cend(), columns_);
}

std::string QueryResult::to_string() const {
    if (!success_) return "Error: " + error_message_;
    
    std::ostringstream ss;
    std::vector<size_t> col_widths(columns_.size());

    for (size_t i = 0; i < columns_.size(); ++i) {
        col_widths[i] = std::max(
            columns_[i].name.length() + type_to_string(columns_[i].get_type()).length() + 3,
            get_max_value_width(i)
        );
    }

    print_separator(ss, col_widths);
    for (size_t i = 0; i < columns_.size(); ++i) {
        ss << "| " << std::left << std::setw(col_widths[i] - 2) 
           << columns_[i].name << " ";
    }
    ss << "|\n";

    for (size_t i = 0; i < columns_.size(); ++i) {
        ss << "| " << std::left << std::setw(col_widths[i] - 2) 
           << type_to_string(columns_[i].get_type()) << " ";
    }
    ss << "|\n";
    
    print_separator(ss, col_widths);

    for (const auto& row : data_) {
        for (size_t i = 0; i < row.size(); ++i) {
            ss << "| " << std::left << std::setw(col_widths[i] - 2)
               << (row[i].has_value() ? row[i]->to_string() : "NULL") << " ";
        }
        ss << "|\n";
    }
    
    print_separator(ss, col_widths);
    return ss.str();
}

void QueryResult::print_separator(std::ostringstream& ss, const std::vector<size_t>& widths) const {
    for (size_t width : widths) {
        ss << "+" << std::string(width, '-');
    }
    ss << "+\n";
}

size_t QueryResult::get_max_value_width(size_t col_idx) const {
    size_t max_width = 4; 
    for (const auto& row : data_) {
        if (row[col_idx].has_value()) {
            max_width = std::max(max_width, row[col_idx]->to_string().length());
        }
    }
    return max_width + 2;
}

std::string QueryResult::type_to_string(Type type) {
    switch (type) {
        case Type::Int32: return "int32";
        case Type::String: return "string";
        case Type::Bool: return "bool";
        case Type::Bytes: return "bytes";
        default: return "unknown";
    }
}

} // namespace core
} // namespace memdb
```
QueryResultIterator.cpp
```
#include "memdb/core/QueryResultIterator.h"

namespace memdb {
namespace core {

ResultRow QueryResultIterator::operator*() const {
    return ResultRow(*data_iter_, *columns_);
}

QueryResultIterator& QueryResultIterator::operator++() {
    ++data_iter_;
    return *this;
}

bool QueryResultIterator::operator!=(const QueryResultIterator& other) const {
    return data_iter_ != other.data_iter_;
}

} // namespace core
} // namespace memdb
```
ResultRow.cpp
```
#include "memdb/core/ResultRow.h"

namespace memdb {
namespace core {

ResultRow::ResultRow(const std::vector<std::optional<Value>>& values, const std::vector<ColumnInfo>& columns)
    : row_map_() 
{
    for (size_t i = 0; i < columns.size(); ++i) {
        if (values[i].has_value()) {
            row_map_[columns[i].name] = values[i].value();
        }
    }
}

const std::optional<Value>& ResultRow::operator[](const std::string& column_name) const {
    auto it = row_map_.find(column_name);
    if (it != row_map_.end()) {
        return it->second;
    }
    static std::optional<Value> empty;
    return empty;
}

} // namespace core
} // namespace memdb
```
Row.cpp
```
#include "memdb/core/Row.h"

namespace memdb {
namespace core {

Row::Row(RowID id, const std::vector<std::optional<Value>>& values) : id_(id), values_(values) {}

RowID Row::get_id() const {
    return id_;
}

std::vector<std::optional<Value>>& Row::get_values() {
    return values_;
}

const std::vector<std::optional<Value>>& Row::get_values() const {
    return values_;
}

std::optional<Value>& Row::get_value(size_t index) {
    if (index >= values_.size()) {
        throw std::out_of_range("Column index out of range.");
    }
    return values_[index];
}

const std::optional<Value>& Row::get_value(size_t index) const {
    if (index >= values_.size()) {
        throw std::out_of_range("Column index out of range.");
    }
    return values_[index];
}

void Row::set_value(size_t index, const Value& value) {
    if (index >= values_.size()) {
        throw std::out_of_range("Column index out of range.");
    }
    values_[index] = value;
}

} // namespace core
} // namespace memdb
```
Table.cpp
```
#include "memdb/core/Row.h"
#include "memdb/core/Table.h"
#include "memdb/core/QueryParser.h"

#include "memdb/core/exceptions/DatabaseException.h"

namespace memdb {
namespace core {

using json = nlohmann::json;

// ======= Table Implementation =======

Table::Table(const std::string& name, const std::vector<Column>& columns) : name_(name), columns_(columns), next_row_id_(1) {
    if (name_.empty()) {
        throw std::invalid_argument("Table name cannot be empty.");
    }

    std::unordered_map<std::string, bool> column_names;
    for (const auto& column : columns_) {
        if (column_names.find(column.get_name()) != column_names.end()) {
            throw std::invalid_argument("Duplicate column name: " + column.get_name());
        }
        column_names[column.get_name()] = true;
    }
}

const std::string& Table::get_name() const {
    return name_;
}

const std::vector<Column>& Table::get_columns() const {
    return columns_;
}

size_t Table::get_column_index(const std::string& column_name) const {
    for (size_t i = 0; i < columns_.size(); ++i) {
        if (columns_[i].get_name() == column_name) {
            return i;
        }
    }
    throw std::invalid_argument("Column not found: " + column_name);
}

void Table::add_column(const Column& column) {
    if (has_column(column.get_name())) {
        throw std::invalid_argument("Column already exists: " + column.get_name());
    }

    columns_.push_back(column);

    for (auto& [id, row] : rows_) {
        if (column.get_default_value()) {
            row.get_values().emplace_back(*(column.get_default_value()));
        }
        else if (column.get_type().is_string()) {
            row.get_values().emplace_back(std::string());
        }
        else if (column.get_type().is_bytes()) {
            row.get_values().emplace_back(std::vector<uint8_t>());
        }
        else if (column.get_type().is_int32()) {
            row.get_values().emplace_back(int32_t(0));
        }
        else if (column.get_type().is_bool()) {
            row.get_values().emplace_back(bool(false));
        }
        else {
            row.get_values().emplace_back(std::nullopt);
        }
    }
}

bool Table::has_column(const std::string& column_name) const {
    for (const auto& column : columns_) {
        if (column.get_name() == column_name) {
            return true;
        }
    }
    return false;
}

RowID Table::insert_row(const std::vector<std::optional<Value>>& values) {
    validate_row(values);

    std::vector<std::optional<Value>> complete_values;
    complete_values.reserve(columns_.size());

    for (size_t i = 0; i < columns_.size(); ++i) {
        if (i < values.size() && values[i].has_value()) {
            complete_values.emplace_back(values[i]);
        }
        else {
            const auto& column = columns_[i];
            if (column.has_attribute(ColumnAttribute::AutoIncrement)) {
                complete_values.emplace_back(static_cast<int32_t>(next_row_id_));
            }
            else if (column.get_default_value()) {
                complete_values.emplace_back(*(column.get_default_value()));
            }
            else {
                complete_values.emplace_back(std::nullopt);
            }
        }
    }

    RowID new_id = next_row_id_++;
    rows_.emplace(new_id, Row(new_id, complete_values));
    return new_id;
}

RowID Table::insert_row(const std::vector<std::optional<Value>>& values, RowID id) {
    validate_row(values);

    std::vector<std::optional<Value>> complete_values = values;

    for (size_t i = 0; i < columns_.size(); ++i) {
        const auto& column = columns_[i];

        if (column.has_attribute(ColumnAttribute::AutoIncrement) && !complete_values[i].has_value()) {
            complete_values[i] = static_cast<int32_t>(next_row_id_);
        }
        else if (!complete_values[i].has_value() && column.get_default_value()) {
            complete_values[i] = *(column.get_default_value());
        }
    }

    RowID new_id;
    if (id != 0) {
        new_id = id;
        if (new_id >= next_row_id_) {
            next_row_id_ = new_id + 1;
        }
    }
    else {
        new_id = next_row_id_++;
    }

    for (size_t i = 0; i < columns_.size(); ++i) {
        const auto& column = columns_[i];
        if (column.has_attribute(ColumnAttribute::Unique) || column.has_attribute(ColumnAttribute::Key)) {
            if (complete_values[i].has_value()) {
                const Value& new_val = *(complete_values[i]);

                for (const auto& [existing_id, existing_row] : rows_) {
                    if (existing_id == new_id) {
                        continue;
                    }

                    const auto& existing_val_opt = existing_row.get_value(i);
                    if (existing_val_opt.has_value()) {
                        const Value& existing_val = *(existing_val_opt);

                        if (new_val.get_type() != existing_val.get_type()) {
                            continue;
                        }

                        bool equal = false;
                        switch (new_val.get_type()) {
                            case Type::Int32:
                                equal = (new_val.get_int() == existing_val.get_int());
                                break;
                            case Type::Bool:
                                equal = (new_val.get_bool() == existing_val.get_bool());
                                break;
                            case Type::String:
                                equal = (new_val.get_string() == existing_val.get_string());
                                break;
                            case Type::Bytes:
                                equal = (new_val.get_bytes() == existing_val.get_bytes());
                                break;
                            default:
                                break;
                        }

                        if (equal) {
                            throw std::invalid_argument("Duplicate value for unique/key column '" + column.get_name() + "'.");
                        }
                    }
                }
            }
        }
    }

    rows_.emplace(new_id, Row(new_id, complete_values));
    return new_id;
}

void Table::delete_row(RowID id) {
    auto it = rows_.find(id);
    if (it != rows_.end()) {
        rows_.erase(it);
    }
    else {
        throw std::invalid_argument("Row ID not found: " + std::to_string(id));
    }
}

Row& Table::get_row(RowID id) {
    auto it = rows_.find(id);
    if (it != rows_.end()) {
        return it->second;
    }
    throw std::invalid_argument("Row ID not found: " + std::to_string(id));
}

const Row& Table::get_row(RowID id) const {
    auto it = rows_.find(id);
    if (it != rows_.end()) {
        return it->second;
    }
    throw std::invalid_argument("Row ID not found: " + std::to_string(id));
}

std::unordered_map<RowID, Row>& Table::get_all_rows() {
    return rows_;
}

const std::unordered_map<RowID, Row>& Table::get_all_rows() const {
    return rows_;
}


void Table::add_index(const std::string& index_type_str, const std::vector<std::string>& columns) {
    IndexType index_type;
    if (index_type_str == "ordered") {
        index_type = IndexType::Ordered;
    }
    else if (index_type_str == "unordered") {
        index_type = IndexType::Unordered;
    }
    else {
        throw std::invalid_argument("Unknown index type: " + index_type_str);
    }

    std::unique_ptr<Index> index = std::make_unique<Index>(index_type, columns);

    for (const auto& [row_id, row] : rows_) {
        std::unordered_map<std::string, Value> row_map;
        for (const auto& col_name : columns) {
            size_t col_index = get_column_index(col_name);
            if (row.get_values()[col_index].has_value()) {
                row_map[col_name] = *(row.get_values()[col_index]);
            }
            else {
                throw std::invalid_argument("Cannot index NULL value in column '" + col_name + "'.");
            }
        }
        index->add_row(row_id, row_map);
    }

    indexes_.emplace_back(std::move(index));
}

std::vector<RowID> Table::find_rows(const std::unique_ptr<Expression>& condition) const {
    std::vector<RowID> matching_rows;
    for (const auto& [row_id, row] : rows_) {
        std::unordered_map<std::string, Value> row_map;
        for (size_t i = 0; i < columns_.size(); ++i) {
            if (row.get_values()[i].has_value()) {
                row_map[columns_[i].get_name()] = *(row.get_values()[i]);
            }
        }

        bool match = true;
        if (condition) {
            Value cond = condition->evaluate(row_map);
            if (cond.get_type() != Type::Bool) {
                throw std::invalid_argument("WHERE clause does not evaluate to a boolean.");
            }
            match = cond.get_bool();
        }

        if (match) {
            matching_rows.push_back(row_id);
        }
    }

    return matching_rows;
}

void Table::validate_row(const std::vector<std::optional<Value>>& values) const {
    if (values.size() > columns_.size()) {
        throw std::invalid_argument("Too many values provided for insertion.");
    }

    for (size_t i = 0; i < values.size(); ++i) {
        if (!values[i].has_value()) {
            continue;
        }

        const auto& value = *(values[i]);
        const auto& column = columns_[i];

        if (value.get_type() != column.get_type().get_type()) {
            throw std::invalid_argument("Type mismatch for column '" + column.get_name() +
                                        "'. Expected: " + column.get_type().to_string() +
                                        ", Got: " + value.to_string());
        }

        // for String and Bytes
        if (column.get_type().is_string()) {
            if (value.get_string().size() > column.get_type().get_size()) {
                throw std::invalid_argument("Value for column '" + column.get_name() +
                                            "' exceeds maximum length.");
            }
        }
        else if (column.get_type().is_bytes()) {
            if (value.get_bytes().size() > column.get_type().get_size()) {
                throw std::invalid_argument("Value for column '" + column.get_name() +
                                            "' exceeds maximum byte size.");
            }
        }
    }

    for (size_t i = 0; i < values.size(); ++i) {
        if (!values[i].has_value()) {
            continue;
        }

        const auto& column = columns_[i];
        if (column.has_attribute(ColumnAttribute::Unique) || column.has_attribute(ColumnAttribute::Key)) {
            const Value& new_value = *(values[i]);

            for (const auto& [existing_id, existing_row] : rows_) {
                const auto& existing_value_opt = existing_row.get_value(i);
                if (existing_value_opt.has_value()) {
                    const Value& existing_value = *(existing_value_opt);
                    if (new_value.get_type() == existing_value.get_type()) {
                        bool equal = false;
                        switch (new_value.get_type()) {
                            case Type::Int32:
                                equal = (new_value.get_int() == existing_value.get_int());
                                break;
                            case Type::Bool:
                                equal = (new_value.get_bool() == existing_value.get_bool());
                                break;
                            case Type::String:
                                equal = (new_value.get_string() == existing_value.get_string());
                                break;
                            case Type::Bytes:
                                equal = (new_value.get_bytes() == existing_value.get_bytes());
                                break;
                            default:
                                break;
                        }
                        if (equal) {
                            throw std::invalid_argument("Duplicate value for unique/key column '" +
                                                        column.get_name() + "'.");
                        }
                    }
                }
            }
        }
    }
}

nlohmann::json Table::to_json() const {
    nlohmann::json j;
    j["name"] = name_;

    j["columns"] = nlohmann::json::array();
    for (const auto& column : columns_) {
        nlohmann::json col_json;
        col_json["name"] = column.get_name();
        col_json["type"] = column.get_type().to_string();

        nlohmann::json attrs = nlohmann::json::array();
        for (const auto& attr : column.get_attributes()) {
            switch (attr) {
                case ColumnAttribute::Unique:
                    attrs.push_back("unique");
                    break;
                case ColumnAttribute::AutoIncrement:
                    attrs.push_back("autoincrement");
                    break;
                case ColumnAttribute::Key:
                    attrs.push_back("key");
                    break;
                default:
                    attrs.push_back("unknown");
            }
        }
        col_json["attributes"] = attrs;

        if (column.get_default_value()) {
            col_json["default"] = column.get_default_value()->to_string();
        }

        j["columns"].push_back(col_json);
    }

    j["rows"] = nlohmann::json::array();
    for (const auto& [id, row] : rows_) {
        nlohmann::json row_json;
        row_json["id"] = id;
        row_json["values"] = nlohmann::json::array();
        for (const auto& value : row.get_values()) {
            if (value.has_value()) {
                switch (value->get_type()) {
                    case Type::Int32:
                        row_json["values"].push_back(value->get_int());
                        break;
                    case Type::Bool:
                        row_json["values"].push_back(value->get_bool());
                        break;
                    case Type::String:
                        row_json["values"].push_back(value->get_string());
                        break;
                    case Type::Bytes:
                        {
                            const auto& bytes = value->get_bytes();
                            std::string hex_str = "0x";
                            const char hex_chars[] = "0123456789ABCDEF";
                            for (uint8_t byte : bytes) {
                                hex_str += hex_chars[(byte >> 4) & 0xF];
                                hex_str += hex_chars[byte & 0xF];
                            }
                            row_json["values"].push_back(hex_str);
                        }
                        break;
                    default:
                        row_json["values"].push_back(nullptr);
                        break;
                }
            }
            else {
                row_json["values"].push_back(nullptr);
            }
        }
        j["rows"].push_back(row_json);
    }

    return j;
}

Table Table::from_json(const nlohmann::json& j) {
    std::string table_name = j.at("name").get<std::string>();
    std::vector<Column> columns;

    for (const auto& col_json : j.at("columns")) {
        std::string col_name = col_json.at("name").get<std::string>();
        std::string col_type_str = col_json.at("type").get<std::string>();

        Type type;
        size_t size = 0;
        if (col_type_str.find("int32") != std::string::npos) {
            type = Type::Int32;
        }
        else if (col_type_str.find("bool") != std::string::npos) {
            type = Type::Bool;
        }
        else if (col_type_str.find("string") != std::string::npos) {
            type = Type::String;
            size = std::stoul(col_type_str.substr(col_type_str.find('[') + 1,
                        col_type_str.find_last_of(']') - col_type_str.find('[') - 1));
        }
        else if (col_type_str.find("bytes") != std::string::npos) {
            type = Type::Bytes;
            size = std::stoul(col_type_str.substr(col_type_str.find('[') + 1,
                        col_type_str.find_last_of(']') - col_type_str.find('[') - 1));
        }
        else {
            throw exceptions::SerializationException("Unknown column type: " + col_type_str);
        }

        std::vector<ColumnAttribute> attributes;
        for (const auto& attr : col_json.at("attributes")) {
            std::string attr_str = attr.get<std::string>();
            if (attr_str == "unique") {
                attributes.emplace_back(ColumnAttribute::Unique);
            }
            else if (attr_str == "autoincrement") {
                attributes.emplace_back(ColumnAttribute::AutoIncrement);
            }
            else if (attr_str == "key") {
                attributes.emplace_back(ColumnAttribute::Key);
            }
            else {
                // TODO: unknown attributes
            }
        }

        std::optional<Value> default_value = std::nullopt;
        if (col_json.contains("default")) {
            std::string default_val_str = col_json.at("default").get<std::string>();
            switch (type) {
                case Type::Int32:
                    default_value = Value(static_cast<int32_t>(std::stoi(default_val_str)));
                    break;
                case Type::Bool:
                    default_value = Value((default_val_str == "true"));
                    break;
                case Type::String:
                    if (default_val_str.front() == '"' && default_val_str.back() == '"') {
                        default_val_str = default_val_str.substr(1, default_val_str.size() - 2);
                    }
                    default_value = Value(default_val_str);
                    break;
                case Type::Bytes:
                {
                    std::string hex_str = default_val_str;
                    if (hex_str.find("0x") != 0 && hex_str.find("0X") != 0) {
                        throw exceptions::SerializationException("Invalid bytes format.");
                    }
                    hex_str = hex_str.substr(2);
                    if (hex_str.size() % 2 != 0) {
                        throw exceptions::SerializationException("Invalid hex length for bytes.");
                    }
                    std::vector<uint8_t> bytes;
                    bytes.reserve(hex_str.size() / 2);
                    for (size_t i = 0; i < hex_str.size(); i += 2) {
                        uint8_t byte = static_cast<uint8_t>(std::stoi(hex_str.substr(i, 2), nullptr, 16));
                        bytes.push_back(byte);
                    }
                    default_value = Value(bytes);
                }
                break;
                default:
                    throw exceptions::SerializationException("Unhandled column type: " + col_type_str);
            }
        }

        DataType data_type = (type == Type::String || type == Type::Bytes)
                               ? DataType(type, size)
                               : DataType(type);

        columns.emplace_back(col_name, data_type, attributes, default_value);
    }

    Table table(table_name, columns);

    for (const auto& row_json : j.at("rows")) {
        core::RowID row_id = row_json.at("id").get<core::RowID>();
        std::vector<std::optional<Value>> values;
        const auto& cols = table.get_columns();
        const auto& val_array = row_json.at("values");

        for (size_t i = 0; i < cols.size(); ++i) {
            const auto& col = cols[i];
            const auto& val_json = val_array[i];

            if (val_json.is_null()) {
                values.emplace_back(std::nullopt);
            }
            else {
                switch (col.get_type().get_type()) {
                    case Type::Int32:
                        values.emplace_back(Value(static_cast<int32_t>(val_json.get<int32_t>())));
                        break;
                    case Type::Bool:
                        values.emplace_back(Value(val_json.get<bool>()));
                        break;
                    case Type::String:
                        values.emplace_back(Value(val_json.get<std::string>()));
                        break;
                    case Type::Bytes:
                        {
                            std::string hex_str = val_json.get<std::string>();
                            if (hex_str.find("0x") != 0 && hex_str.find("0X") != 0) {
                                throw exceptions::SerializationException("Invalid bytes format.");
                            }
                            hex_str = hex_str.substr(2);
                            if (hex_str.size() % 2 != 0) {
                                throw exceptions::SerializationException("Invalid hex length for bytes.");
                            }
                            std::vector<uint8_t> bytes;
                            bytes.reserve(hex_str.size() / 2);
                            for (size_t j = 0; j < hex_str.size(); j += 2) {
                                uint8_t byte = static_cast<uint8_t>(std::stoi(hex_str.substr(j, 2), nullptr, 16));
                                bytes.push_back(byte);
                            }
                            values.emplace_back(Value(bytes));
                        }
                        break;
                    default:
                        throw exceptions::SerializationException("Unknown column type: " + col.get_type().to_string());
                }
            }
        }

        table.insert_row(values, row_id);
    }

    return table;
}

std::string Table::to_string() const {
    std::ostringstream oss;
    oss << "Table: " << name_ << "\nColumns:\n";
    for (const auto& column : columns_) {
        oss << "  " << column.to_string() << "\n";
    }
    oss << "Rows:\n";
    for (const auto& [id, row] : rows_) {
        oss << "  RowID " << id << ": ";
        for (size_t i = 0; i < row.get_values().size(); ++i) {
            if (i > 0) oss << ", ";
            if (row.get_values()[i].has_value()) {
                oss << row.get_values()[i]->to_string();
            } else {
                oss << "NULL";
            }
        }
        oss << "\n";
    }
    return oss.str();
}

} // namespace core
} // namespace memdb
```
Value.cpp
```
#include "memdb/core/Value.h"

#include "memdb/core/exceptions/TypeMismatchException.h"

namespace memdb {
namespace core {

// ======= Value Implementation =======

Value::Value(int32_t int_val) 
    : data_(int_val) {}

Value::Value(bool bool_val) 
    : data_(bool_val) {}

Value::Value(const std::string& str_val) 
    : data_(str_val) {}

Value::Value(const std::vector<uint8_t>& bytes_val) 
    : data_(bytes_val) {}

Type Value::get_type() const {
    if (!data_) {
        return Type::Unknown;
    }
    return std::visit([](auto&& arg) -> Type {
        using T = std::decay_t<decltype(arg)>;
        if constexpr (std::is_same_v<T, int32_t>) {
            return Type::Int32;
        } else if constexpr (std::is_same_v<T, bool>) {
            return Type::Bool;
        } else if constexpr (std::is_same_v<T, std::string>) {
            return Type::String;
        } else if constexpr (std::is_same_v<T, std::vector<uint8_t>>) {
            return Type::Bytes;
        } else {
            return Type::Unknown;
        }
    }, *data_);
}

bool Value::has_value() const {
    return data_.has_value();
}

int32_t Value::get_int() const {
    if (!data_ || !std::holds_alternative<int32_t>(*data_)) {
        throw exceptions::TypeMismatchException("Value is not of type Int32.");
    }
    return std::get<int32_t>(*data_);
}

bool Value::get_bool() const {
    if (!data_ || !std::holds_alternative<bool>(*data_)) {
        throw exceptions::TypeMismatchException("Value is not of type Bool.");
    }
    return std::get<bool>(*data_);
}

const std::string& Value::get_string() const {
    if (!data_ || !std::holds_alternative<std::string>(*data_)) {
        throw exceptions::TypeMismatchException("Value is not of type String.");
    }
    return std::get<std::string>(*data_);
}

const std::vector<uint8_t>& Value::get_bytes() const {
    if (!data_ || !std::holds_alternative<std::vector<uint8_t>>(*data_)) {
        throw exceptions::TypeMismatchException("Value is not of type Bytes.");
    }
    return std::get<std::vector<uint8_t>>(*data_);
}

const std::variant<int32_t, bool, std::string, std::vector<uint8_t>>& Value::get_variant() const {
    if (!data_) {
        throw exceptions::TypeMismatchException("Attempted to get variant of NULL Value.");
    }
    return *data_;
}

std::variant<int32_t, bool, std::string, std::vector<uint8_t>>& Value::get_variant() {
    if (!data_) {
        throw exceptions::TypeMismatchException("Attempted to get variant of NULL Value.");
    }
    return *data_;
}

void Value::set_int(int32_t int_val) {
    if (data_ && !std::holds_alternative<int32_t>(*data_)) {
        throw exceptions::TypeMismatchException("Cannot set Int32 on Value of different type.");
    }
    data_ = int_val;
}

void Value::set_bool(bool bool_val) {
    if (data_ && !std::holds_alternative<bool>(*data_)) {
        throw exceptions::TypeMismatchException("Cannot set Bool on Value of different type.");
    }
    data_ = bool_val;
}

void Value::set_string(const std::string& str_val) {
    if (data_ && !std::holds_alternative<std::string>(*data_)) {
        throw exceptions::TypeMismatchException("Cannot set String on Value of different type.");
    }
    data_ = str_val;
}

void Value::set_bytes(const std::vector<uint8_t>& bytes_val) {
    if (data_ && !std::holds_alternative<std::vector<uint8_t>>(*data_)) {
        throw exceptions::TypeMismatchException("Cannot set Bytes on Value of different type.");
    }
    data_ = bytes_val;
}

std::string Value::to_string() const {
    if (!data_) {
        return "NULL";
    }

    switch (data_->index()) {
        case 0: // int32_t
            return std::to_string(std::get<int32_t>(*data_));
        case 1: // bool
            return std::get<bool>(*data_) ? "true" : "false";
        case 2: // std::string
            return "\"" + std::get<std::string>(*data_) + "\"";
        case 3: // std::vector<uint8_t>
        {
            const auto& bytes = std::get<std::vector<uint8_t>>(*data_);
            std::string hex_str = "0x";
            const char hex_chars[] = "0123456789ABCDEF";
            for (uint8_t byte : bytes) {
                hex_str += hex_chars[(byte >> 4) & 0xF];
                hex_str += hex_chars[byte & 0xF];
            }
            return hex_str;
        }
        default:
            return "unknown";
    }
}

} // namespace core
} // namespace memdb
```
TestCreateTable.cpp
```
#include <gtest/gtest.h>
#include "memdb/core/QueryParser.h"
#include "memdb/core/Database.h"
#include "memdb/core/Table.h"

TEST(CreateTableTest, SuccessfulCreation) {
    memdb::core::Database db;
    std::string query = "create table users ({key, autoincrement} id : int32, {unique} login: string[32], password_hash: bytes[8], is_admin: bool = false);";
    
    try {
        memdb::core::ParsedQuery pq = memdb::core::QueryParser().parse(query);
        ASSERT_EQ(pq.type, memdb::core::ParsedQuery::QueryType::CreateTable);
        db.create_table(pq.table_name, pq.columns); 
        
        ASSERT_TRUE(db.has_table("users"));
        auto table = db.get_table("users");
        ASSERT_EQ(table->get_name(), "users");
        ASSERT_EQ(table->get_columns().size(), 4);
    }
    catch (const std::exception& e) {
        FAIL() << "Exception thrown during successful creation: " << e.what();
    }
}

TEST(CreateTableTest, DuplicateColumnNames) {
    memdb::core::Database db;
    std::string query = "create table users ({key, autoincrement} id : int32, {unique} id: string[32], password_hash: bytes[8]);";
    
    try {
        memdb::core::ParsedQuery pq = memdb::core::QueryParser().parse(query);
        db.create_table(pq.table_name, pq.columns); 
        FAIL() << "Expected exception for duplicate column names.";
    }
    catch (const std::invalid_argument& e) {
        EXPECT_STREQ(e.what(), "Duplicate column name: id");
    }
    catch (...) {
        FAIL() << "Expected std::invalid_argument for duplicate column names.";
    }
}

TEST(CreateTableTest, UnknownColumnType) {
    memdb::core::Database db;
    std::string query = "create table users ({key} id : int64, {unique} login: string[32]);";
    
    try {
        memdb::core::ParsedQuery pq = memdb::core::QueryParser().parse(query);
        db.create_table(pq.table_name, pq.columns); 
        FAIL() << "Expected exception for unknown column type.";
    }
    catch (const std::invalid_argument& e) {
        EXPECT_STREQ(e.what(), "Unknown column type: int64");
    }
    catch (...) {
        FAIL() << "Expected std::invalid_argument for unknown column type.";
    }
}

TEST(CreateTableTest, EmptyTableName) {
    memdb::core::Database db;
    std::string query = "create table () {key} id : int32;";
    
    try {
        memdb::core::ParsedQuery pq = memdb::core::QueryParser().parse(query);
        db.create_table(pq.table_name, pq.columns); 
        FAIL() << "Expected exception for empty table name.";
    }
    catch (const std::invalid_argument& e) {
        EXPECT_STREQ(e.what(), "Table name cannot be empty.");
    }
    catch (...) {
        FAIL() << "Expected std::invalid_argument for empty table name.";
    }
}

TEST(CreateTableTest, CreateTableWithNoColumns) {
    memdb::core::Database db;
    std::string query = "create table empty_table ();";
    
    try {
        memdb::core::ParsedQuery pq = memdb::core::QueryParser().parse(query);
        db.create_table(pq.table_name, pq.columns); 
        FAIL() << "Expected exception for creating table with no columns.";
    }
    catch (const std::invalid_argument& e) {
        EXPECT_STREQ(e.what(), "Column definitions cannot be empty");
    }
    catch (...) {
        FAIL() << "Expected std::invalid_argument for creating table with no columns.";
    }
}

TEST(CreateTableTest, InvalidColumnAttributes) {
    memdb::core::Database db;
    std::string query = "create table users ({invalid_attr} id : int32, login: string[32]);";
    
    try {
        memdb::core::ParsedQuery pq = memdb::core::QueryParser().parse(query);
        db.create_table(pq.table_name, pq.columns); 
        FAIL() << "Expected exception for invalid column attributes.";
    }
    catch (const std::invalid_argument& e) {
        EXPECT_STREQ(e.what(), "Unknown column attribute: invalid_attr");
    }
    catch (...) {
        FAIL() << "Expected std::invalid_argument for invalid column attributes.";
    }
}

TEST(CreateTableTest, UnbalancedParentheses) {
    memdb::core::Database db;
    std::string query = "create table users ({key} id : int32, login: string[32];"; 
    
    try {
        memdb::core::ParsedQuery pq = memdb::core::QueryParser().parse(query);
        db.create_table(pq.table_name, pq.columns); 
        FAIL() << "Expected exception for unbalanced parentheses.";
    }
    catch (const std::invalid_argument& e) {
        EXPECT_STREQ(e.what(), "Unbalanced parentheses or braces in query.");
    }
    catch (...) {
        FAIL() << "Expected std::invalid_argument for unbalanced parentheses.";
    }
}

TEST(CreateTableTest, MissingColon) {
    memdb::core::Database db;
    std::string query = "create table users ({key} id int32, login: string[32]);"; 
    
    try {
        memdb::core::ParsedQuery pq = memdb::core::QueryParser().parse(query);
        db.create_table(pq.table_name, pq.columns); 
        FAIL() << "Expected exception for missing colon in column definition.";
    }
    catch (const std::invalid_argument& e) {
        EXPECT_STREQ(e.what(), "Expected ':' in column definition.");
    }
    catch (...) {
        FAIL() << "Expected std::invalid_argument for missing colon in column definition.";
    }
}

TEST(CreateTableTest, InvalidDefaultValue) {
    memdb::core::Database db;
    std::string query = "create table users ({key} id : int32 = \"invalid\", login: string[32]);";
    
    try {
        memdb::core::ParsedQuery pq = memdb::core::QueryParser().parse(query);
        db.create_table(pq.table_name, pq.columns); 
        FAIL() << "Expected exception for invalid default value type.";
    }
    catch (const std::invalid_argument& e) {
        EXPECT_NE(std::string(e.what()), "Type mismatch for column 'id'.");
    }
    catch (...) {
        FAIL() << "Expected std::invalid_argument for invalid default value type.";
    }
}

TEST(CreateTableTest, MultipleTablesWithAttributes) {
    memdb::core::Database db;
    std::string query1 = "create table users ({key, autoincrement} id : int32, {unique} login: string[32], password_hash: bytes[8], is_admin: bool = false);";
    std::string query2 = "create table products ({key} product_id : int32, name: string[50], price: int32, {unique} sku: string[20]);";
    
    try {
        memdb::core::ParsedQuery pq1 = memdb::core::QueryParser().parse(query1);
        db.create_table(pq1.table_name, pq1.columns); 
        ASSERT_TRUE(db.has_table("users"));
        
        memdb::core::ParsedQuery pq2 = memdb::core::QueryParser().parse(query2);
        db.create_table(pq2.table_name, pq2.columns); 
        ASSERT_TRUE(db.has_table("products"));
        
        auto products_table = db.get_table("products");
        ASSERT_EQ(products_table->get_columns().size(), 4);
        ASSERT_EQ(products_table->get_columns()[0].get_name(), "product_id");
        ASSERT_EQ(products_table->get_columns()[0].get_type().get_type(), memdb::core::Type::Int32);
        ASSERT_TRUE(products_table->get_columns()[0].has_attribute(memdb::core::ColumnAttribute::Key));
    }
    catch (const std::exception& e) {
        FAIL() << "Exception thrown during multiple table creation: " << e.what();
    }
}

TEST(CreateTableTest, VariousDataTypes) {
    memdb::core::Database db;
    std::string query = "create table users (id : int32, name: string[50], data: bytes[16], is_active: bool);";
    
    try {
        memdb::core::ParsedQuery pq = memdb::core::QueryParser().parse(query);
        ASSERT_EQ(pq.columns.size(), 4);
        db.create_table(pq.table_name, pq.columns); 
        
        ASSERT_TRUE(db.has_table("users"));
        auto table = db.get_table("users");
        ASSERT_EQ(table->get_columns()[0].get_type().get_type(), memdb::core::Type::Int32);
        ASSERT_EQ(table->get_columns()[1].get_type().get_type(), memdb::core::Type::String);
        ASSERT_EQ(table->get_columns()[2].get_type().get_type(), memdb::core::Type::Bytes);
        ASSERT_EQ(table->get_columns()[3].get_type().get_type(), memdb::core::Type::Bool);
    }
    catch (const std::exception& e) {
        FAIL() << "Exception thrown during various data types creation: " << e.what();
    }
}

TEST(CreateTableTest, CaseInsensitiveKeywords) {
    memdb::core::Database db;
    std::string query = "CREATE TABLE users ({KEY, AUTOINCREMENT} ID : INT32, {UNIQUE} LOGIN: STRING[32]);";
    
    try {
        memdb::core::ParsedQuery pq = memdb::core::QueryParser().parse(query);
        db.create_table(pq.table_name, pq.columns); 
        
        ASSERT_TRUE(db.has_table("users"));
        auto table = db.get_table("users");
        ASSERT_EQ(table->get_columns().size(), 2);
        ASSERT_TRUE(table->get_columns()[0].has_attribute(memdb::core::ColumnAttribute::Key));
        ASSERT_TRUE(table->get_columns()[0].has_attribute(memdb::core::ColumnAttribute::AutoIncrement));
        ASSERT_TRUE(table->get_columns()[1].has_attribute(memdb::core::ColumnAttribute::Unique));
    }
    catch (const std::exception& e) {
        FAIL() << "Exception thrown during case-insensitive keywords creation: " << e.what();
    }
}

TEST(CreateTableTest, ColumnsWithoutAttributes) {
    memdb::core::Database db;
    std::string query = "create table users (id : int32, login: string[32], is_active: bool);";
    
    try {
        memdb::core::ParsedQuery pq = memdb::core::QueryParser().parse(query);
        db.create_table(pq.table_name, pq.columns); 
        
        ASSERT_TRUE(db.has_table("users"));
        auto table = db.get_table("users");
        ASSERT_EQ(table->get_columns().size(), 3);
        ASSERT_FALSE(table->get_columns()[0].has_attribute(memdb::core::ColumnAttribute::Key));
        ASSERT_FALSE(table->get_columns()[1].has_attribute(memdb::core::ColumnAttribute::Unique));
    }
    catch (const std::exception& e) {
        FAIL() << "Exception thrown during columns without attributes creation: " << e.what();
    }
}

TEST(CreateTableTest, ColumnsWithBracketsInString) {
    memdb::core::Database db;
    std::string query = "create table users (id : int32, description: string[100] = \"User with (parentheses) and {braces}\");";
    
    try {
        memdb::core::ParsedQuery pq = memdb::core::QueryParser().parse(query);
        db.create_table(pq.table_name, pq.columns); 
        
        ASSERT_TRUE(db.has_table("users"));
        auto table = db.get_table("users");
        ASSERT_EQ(table->get_columns().size(), 2);

        auto default_value = table->get_columns()[1].get_default_value();
        ASSERT_TRUE(default_value.has_value());
        ASSERT_EQ(default_value.value().to_string(), "\"User with (parentheses) and {braces}\"");
    }
    catch (const std::exception& e) {
        FAIL() << "Exception thrown during columns with brackets in string creation: " << e.what();
    }
}

TEST(CreateTableTest, MissingAttributes) {
    memdb::core::Database db;
    std::string query = "create table users (id int32, {unique} login: string[32]);";
    
    try {
        memdb::core::ParsedQuery pq = memdb::core::QueryParser().parse(query);
        db.create_table(pq.table_name, pq.columns); 
        FAIL() << "Expected exception for missing ':' in column definition.";
    }
    catch (const std::invalid_argument& e) {
        EXPECT_NE(std::string(e.what()).find("Expected ':' in column definition."), std::string::npos);
    }
    catch (...) {
        FAIL() << "Expected std::invalid_argument for missing ':' in column definition.";
    }
}

TEST(CreateTableTest, DefaultValuesVariousTypes) {
    memdb::core::Database db;
    std::string query = "create table test (id : int32 = -1, flag : bool = true, data : bytes[2] = 0xFF00, name: string[10] = \"default\");";

    try {
        memdb::core::ParsedQuery pq = memdb::core::QueryParser().parse(query);
        db.create_table(pq.table_name, pq.columns);
        auto table = db.get_table("test");

        ASSERT_EQ(table->get_columns()[0].get_default_value().value().get_int(), -1);
        ASSERT_EQ(table->get_columns()[1].get_default_value().value().get_bool(), true);
        ASSERT_EQ(table->get_columns()[2].get_default_value().value().get_bytes(), std::vector<uint8_t>({0xFF, 0x00}));
        ASSERT_EQ(table->get_columns()[3].get_default_value().value().get_string(), "default");

    } catch (const std::exception& e) {
        FAIL() << "Exception thrown: " << e.what();
    }
}

TEST(CreateTableTest, StringAndBytesSizes) {
    memdb::core::Database db;

    std::string query1 = "create table test (data : string[0]);";
    try {
        memdb::core::QueryParser().parse(query1);
        FAIL() << "Expected exception for zero-length string";
    } catch (const std::invalid_argument& e) {
        EXPECT_STREQ(e.what(), "Size can only be set for String and Bytes types with size > 0.");
    }

    std::string query2 = "create table test (data : bytes[1024]);";
    try {
        memdb::core::ParsedQuery pq = memdb::core::QueryParser().parse(query2);
        db.create_table(pq.table_name, pq.columns);
        ASSERT_TRUE(db.has_table("test"));
        auto table = db.get_table("test");
        ASSERT_EQ(table->get_columns()[0].get_type().get_size(), 1024);
    } catch (const std::exception& e) {
        FAIL() << "Exception thrown for large byte size: " << e.what();
    }
}

TEST(CreateTableTest, WhitespaceVariations) {
    memdb::core::Database db;
    std::string query = "   create                           table test     ({ key ,autoincrement}  id  :int32 ,{unique}name :  string[32]);";
    try {
        memdb::core::ParsedQuery pq = memdb::core::QueryParser().parse(query);
        db.create_table(pq.table_name, pq.columns);
        ASSERT_TRUE(db.has_table("test"));
        auto table = db.get_table("test");
        ASSERT_EQ(table->get_columns().size(), 2);
    } catch (const std::exception& e) {
        FAIL() << "Exception thrown for whitespace variations: " << e.what();
    }
}

TEST(CreateTableTest, EmptyAttributeList) {
    memdb::core::Database db;
    std::string query = "create table test ({ } id: int32);";
    try {
        memdb::core::ParsedQuery pq = memdb::core::QueryParser().parse(query);
        db.create_table(pq.table_name, pq.columns);
        ASSERT_TRUE(db.has_table("test"));
        auto table = db.get_table("test");
        ASSERT_EQ(table->get_columns().size(), 1);
    } catch (const std::invalid_argument& e) {
        EXPECT_STREQ(e.what(), "Unknown column attribute: ");
    }

}

TEST(CreateTableTest, MissingDefaultValue) {
    memdb::core::Database db;
    std::string query = "create table test (id: int32 = );";
    try {
        memdb::core::QueryParser().parse(query);
        FAIL() << "Expected exception for missing default value.";
    } catch (const std::invalid_argument& e) {
        EXPECT_NE(std::string(e.what()).find("Invalid default value"), std::string::npos);
    }
}

TEST(CreateTableTest, InvalidCharactersInNames) {
    memdb::core::Database db;
    std::string query1 = "create table test (my id : int32);";
    std::string query2 = "create table test-table (id : int32);";

    try {
        memdb::core::QueryParser().parse(query1);
        FAIL() << "Expected exception for invalid column name.";
    } catch (const std::invalid_argument& e) {
        EXPECT_NE(std::string(e.what()).find("Invalid column name"), std::string::npos);
    }

    try {
        memdb::core::QueryParser().parse(query2);
        FAIL() << "Expected exception for invalid table name.";
    } catch (const std::invalid_argument& e) {
        EXPECT_NE(std::string(e.what()).find("Invalid table name"), std::string::npos);
    }

}

TEST(CreateTableTest, CaseSensitivityTableNames) {
    memdb::core::Database db;
    std::string query1 = "create table MyTable (id : int32);";
    std::string query2 = "create table mytable (id : int32);";

    try {
        memdb::core::ParsedQuery pq1 = memdb::core::QueryParser().parse(query1);
        db.create_table(pq1.table_name, pq1.columns);

        memdb::core::ParsedQuery pq2 = memdb::core::QueryParser().parse(query2);
        db.create_table(pq2.table_name, pq2.columns); 

        ASSERT_TRUE(db.has_table("MyTable"));

    } catch (const std::invalid_argument& e) {
        FAIL() << "Exception thrown for case-sensitivity test: " << e.what();
    }
}

TEST(CreateTableTest, ReservedKeywordsAsTableNames) {
    memdb::core::Database db;
    std::string query = "create table create (id : int32);"; 

    try {
        memdb::core::QueryParser().parse(query);
        FAIL() << "Expected exception for reserved keyword as table name.";
    } catch (const std::invalid_argument& e) {
        EXPECT_NE(e.what(), "Reserved keyword used as table name: create.");
    }
}

TEST(CreateTableTest, ReservedKeywordAsColumnName) {
    memdb::core::Database db;
    std::string query = "create table test (select : int32, from: bool);";
    
    try {
        memdb::core::ParsedQuery pq = memdb::core::QueryParser().parse(query);
        db.create_table(pq.table_name, pq.columns); 
        FAIL() << "Expected exception for reserved keywords as column names.";
    }
    catch (const std::invalid_argument& e) {
        EXPECT_STREQ(e.what(), "Invalid column name: select");
    }
    catch (...) {
        FAIL() << "Expected std::invalid_argument for reserved keywords as column names.";
    }
}

TEST(CreateTableTest, TooLongStringPassed) {
    memdb::core::Database db;
    std::string query = "create table users (id : int32, description: string[10] = \"User with (parentheses) and {braces}\");";

    try {
        memdb::core::QueryParser().parse(query);
        FAIL() << "Expected exception for string exceeding defined size.";
    } catch (const std::invalid_argument& e) {
        EXPECT_STREQ(e.what(), "String value exceeds defined size of 10");
    }
}

TEST(CreateTableTest, TooLongBytesPassed) {
    memdb::core::Database db;
    std::string query = "create table users (id : int32, description: bytes[4] = 0x12345678AB);";

    try {
        memdb::core::QueryParser().parse(query);
        FAIL() << "Expected exception for bytes exceeding defined size.";
    } catch (const std::invalid_argument& e) {
        EXPECT_STREQ(e.what(), "Bytes value exceeds defined size of 4");
    }
}

TEST(CreateTableTest, CreateTableWithMixedAttributes) {
    memdb::core::Database db;
    std::string query = 
        "create table mixed_attrs ("
        "{key, autoincrement} id : int32, "
        "{unique} username: string[32], "
        "email: string[50] = \"\", "
        "{unique, key} phone: string[15]"
        ");";
    
    try {
        memdb::core::ParsedQuery pq = memdb::core::QueryParser().parse(query);
        db.create_table(pq.table_name, pq.columns); 
        
        ASSERT_TRUE(db.has_table("mixed_attrs"));
        auto table = db.get_table("mixed_attrs");
        ASSERT_EQ(table->get_columns().size(), 4);
        
        ASSERT_TRUE(table->get_columns()[0].has_attribute(memdb::core::ColumnAttribute::Key));
        ASSERT_TRUE(table->get_columns()[0].has_attribute(memdb::core::ColumnAttribute::AutoIncrement));
        
        ASSERT_TRUE(table->get_columns()[1].has_attribute(memdb::core::ColumnAttribute::Unique));
        
        ASSERT_FALSE(table->get_columns()[2].has_attribute(memdb::core::ColumnAttribute::Unique));
        ASSERT_TRUE(table->get_columns()[2].get_default_value().has_value());
        
        ASSERT_TRUE(table->get_columns()[3].has_attribute(memdb::core::ColumnAttribute::Unique));
        ASSERT_TRUE(table->get_columns()[3].has_attribute(memdb::core::ColumnAttribute::Key));
    }
    catch (const std::exception& e) {
        FAIL() << "Exception thrown during mixed attributes table creation: " << e.what();
    }
}

int main(int argc, char **argv) {
    ::testing::InitGoogleTest(&argc, argv);
    return RUN_ALL_TESTS();
}
```
TestInsert.cpp
```
#include <gtest/gtest.h>
#include <gmock/gmock.h>
#include "memdb/core/QueryParser.h"
#include "memdb/core/Database.h"
#include "memdb/core/Table.h"

TEST(InsertTest, SuccessfulInsert) {
    memdb::core::Database db;
    memdb::core::QueryParser parser;
    parser.set_database(&db);
    std::string create_query = "create table users (id : int32, name: string[32], age: int32, is_active: bool);";
    memdb::core::ParsedQuery pq_create = parser.parse(create_query);
    db.create_table(pq_create.table_name, pq_create.columns);
    
    std::string insert_query = "insert (1, \"Alice\", 30, true) to users;";
    memdb::core::ParsedQuery pq_insert = parser.parse(insert_query);
    
    EXPECT_NO_THROW(db.insert_row(pq_insert.table_name, *pq_insert.insert_values));
}

TEST(InsertTest, AutoIncrementedID) {
    memdb::core::Database db;
    memdb::core::QueryParser parser;
    parser.set_database(&db);
    
    std::string create_query = "create table users ({key, autoincrement} id : int32, name: string[32]);";
    memdb::core::ParsedQuery pq_create = parser.parse(create_query);
    db.create_table(pq_create.table_name, pq_create.columns);
    
    std::string insert_query1 = "insert (, \"Alice\") to users;";
    std::string insert_query2 = "insert (, \"Bob\") to users;";
    
    EXPECT_NO_THROW({
        memdb::core::ParsedQuery pq_insert1 = parser.parse(insert_query1);
        db.insert_row(pq_insert1.table_name, *pq_insert1.insert_values);
        
        memdb::core::ParsedQuery pq_insert2 = parser.parse(insert_query2);
        db.insert_row(pq_insert2.table_name, *pq_insert2.insert_values);
    });
    
    auto table = db.get_table("users");
    ASSERT_EQ(table->get_all_rows().size(), 2);
    
    const auto& row1 = table->get_row(1);
    const auto& row2 = table->get_row(2);
    
    EXPECT_EQ(row1.get_value(0)->get_int(), 1);
    EXPECT_EQ(row1.get_value(1)->get_string(), "Alice");
    
    EXPECT_EQ(row2.get_value(0)->get_int(), 2);
    EXPECT_EQ(row2.get_value(1)->get_string(), "Bob");
}

TEST(InsertTest, InsertWithUniqueConstraint) {
    memdb::core::Database db;
    memdb::core::QueryParser parser;
    parser.set_database(&db);
    
    std::string create_query = "create table users ({key, autoincrement} id : int32, {unique} email: string[50]);";
    memdb::core::ParsedQuery pq_create = parser.parse(create_query);
    db.create_table(pq_create.table_name, pq_create.columns);
    
    std::string insert_query1 = "insert (, \"alice@example.com\") to users;";
    std::string insert_query2 = "insert (, \"bob@example.com\") to users;";
    std::string insert_query3 = "insert (, \"alice@example.com\") to users;";
    
    EXPECT_NO_THROW({
        memdb::core::ParsedQuery pq_insert1 = parser.parse(insert_query1);
        db.insert_row(pq_insert1.table_name, *pq_insert1.insert_values);
        
        memdb::core::ParsedQuery pq_insert2 = parser.parse(insert_query2);
        db.insert_row(pq_insert2.table_name, *pq_insert2.insert_values);
    });
    
    try {
        memdb::core::ParsedQuery pq_insert3 = parser.parse(insert_query3);
        db.insert_row(pq_insert3.table_name, *pq_insert3.insert_values);
        FAIL() << "Expected exception for duplicate unique column value.";
    } catch (const std::invalid_argument& e) {
        EXPECT_THAT(e.what(), testing::HasSubstr("Duplicate value for unique/key column 'email'"));
    }
}

TEST(InsertTest, StringExceedsSize) {
    memdb::core::Database db;
    memdb::core::QueryParser parser;
    parser.set_database(&db);
    
    std::string create_query = "create table users (id : int32, name: string[5]);";
    memdb::core::ParsedQuery pq_create = parser.parse(create_query);
    db.create_table(pq_create.table_name, pq_create.columns);
    
    std::string insert_query = "insert (1, \"ExceedsSize\") to users;";
    try {
        memdb::core::ParsedQuery pq_insert = parser.parse(insert_query);
        db.insert_row(pq_insert.table_name, *pq_insert.insert_values);
        FAIL() << "Expected exception for string exceeding defined size.";
    } catch (const std::invalid_argument& e) {
        EXPECT_THAT(e.what(), testing::HasSubstr("String value exceeds defined size of 5"));
    }
}

TEST(InsertTest, BytesExceedsSize) {
    memdb::core::Database db;
    memdb::core::QueryParser parser;
    parser.set_database(&db);
    
    std::string create_query = "create table data_table (id : int32, data: bytes[4]);";
    memdb::core::ParsedQuery pq_create = parser.parse(create_query);
    db.create_table(pq_create.table_name, pq_create.columns);
    
    std::string insert_query = "insert (1, 0x1234567890) to data_table;";
    try {
        memdb::core::ParsedQuery pq_insert = parser.parse(insert_query);
        db.insert_row(pq_insert.table_name, *pq_insert.insert_values);
        FAIL() << "Expected exception for bytes exceeding defined size.";
    } catch (const std::invalid_argument& e) {
        EXPECT_THAT(e.what(), testing::HasSubstr("Bytes value exceeds defined size of 4"));
    }
}

TEST(InsertTest, MissingValues) {
    memdb::core::Database db;
    memdb::core::QueryParser parser;
    parser.set_database(&db);
    
    std::string create_query = "create table users (id : int32, name: string[32], age: int32);";
    memdb::core::ParsedQuery pq_create = parser.parse(create_query);
    db.create_table(pq_create.table_name, pq_create.columns);
    
    std::string insert_query = "insert (1, \"Bob\") to users;";
    try {
        memdb::core::ParsedQuery pq_insert = parser.parse(insert_query);
        db.insert_row(pq_insert.table_name, *pq_insert.insert_values);
        FAIL() << "Expected exception for missing values.";
    } catch (const std::invalid_argument& e) {
        EXPECT_THAT(e.what(), testing::HasSubstr("Missing value for column: age"));
    }
}

TEST(InsertTest, ExtraValues) {
    memdb::core::Database db;
    memdb::core::QueryParser parser;
    parser.set_database(&db);
    
    std::string create_query = "create table users (id : int32, name: string[32]);";
    memdb::core::ParsedQuery pq_create = parser.parse(create_query);
    db.create_table(pq_create.table_name, pq_create.columns);
    
    std::string insert_query = "insert (1, \"Charlie\", 25) to users;";
    try {
        memdb::core::ParsedQuery pq_insert = parser.parse(insert_query);
        db.insert_row(pq_insert.table_name, *pq_insert.insert_values);
        FAIL() << "Expected exception for extra values.";
    } catch (const std::invalid_argument& e) {
        EXPECT_THAT(e.what(), testing::HasSubstr("Too many values for table columns"));
    }
}

TEST(InsertTest, InvalidDataTypes) {
    memdb::core::Database db;
    memdb::core::QueryParser parser;
    parser.set_database(&db);
    
    std::string create_query = "create table users (id : int32, name: string[32], is_active: bool);";
    memdb::core::ParsedQuery pq_create = parser.parse(create_query);
    db.create_table(pq_create.table_name, pq_create.columns);
    
    std::string insert_query = "insert (2, \"David\", \"true\") to users;";
    try {
        memdb::core::ParsedQuery pq_insert = parser.parse(insert_query);
        db.insert_row(pq_insert.table_name, *pq_insert.insert_values);
        FAIL() << "Expected exception for invalid data type.";
    } catch (const std::invalid_argument& e) {
        EXPECT_THAT(e.what(), testing::HasSubstr("Invalid type for column 'is_active'"));
    }
}

TEST(InsertTest, ReservedKeywordAsValue) {
    memdb::core::Database db;
    memdb::core::QueryParser parser;
    parser.set_database(&db);
    
    std::string create_query = "create table users (id : int32, keyword_field: string[10]);";
    memdb::core::ParsedQuery pq_create = parser.parse(create_query);
    db.create_table(pq_create.table_name, pq_create.columns);
    
    std::string insert_query = "insert (3, \"select\") to users;";
    EXPECT_NO_THROW({
        memdb::core::ParsedQuery pq_insert = parser.parse(insert_query);
        db.insert_row(pq_insert.table_name, *pq_insert.insert_values);
    });
}

TEST(InsertTest, InsertIntoNonExistentTable) {
    memdb::core::Database db;
    memdb::core::QueryParser parser;
    parser.set_database(&db);
    
    std::string insert_query = "insert (1, \"Eve\", 28) to nonexistent_table;";
    try {
        memdb::core::ParsedQuery pq_insert = parser.parse(insert_query);
        db.insert_row(pq_insert.table_name, *pq_insert.insert_values);
        FAIL() << "Expected exception for inserting into non-existent table.";
    } catch (const std::invalid_argument& e) {
        EXPECT_THAT(e.what(), testing::HasSubstr("Table does not exist: nonexistent_table"));
    }
}

TEST(InsertTest, InsertWithDefaultValues) {
    memdb::core::Database db;
    memdb::core::QueryParser parser;
    parser.set_database(&db);
    
    std::string create_query = "create table users (id : int32, name: string[32], age: int32 = 25);";
    memdb::core::ParsedQuery pq_create = parser.parse(create_query);
    db.create_table(pq_create.table_name, pq_create.columns);
    
    std::string insert_query = "insert (1, \"Frank\") to users;";
    EXPECT_NO_THROW({
        memdb::core::ParsedQuery pq_insert = parser.parse(insert_query);
        db.insert_row(pq_insert.table_name, *pq_insert.insert_values);
    });
    
    auto table = db.get_table("users");
    ASSERT_EQ(table->get_all_rows().size(), 1);
}

TEST(InsertTest, InsertWithSpecialCharacters) {
    memdb::core::Database db;
    memdb::core::QueryParser parser;
    parser.set_database(&db);
    
    std::string create_query = "create table users (id : int32, bio: string[100]);";
    memdb::core::ParsedQuery pq_create = parser.parse(create_query);
    db.create_table(pq_create.table_name, pq_create.columns);
    
    std::string insert_query = "insert (1, \"Bio with (parentheses) and {braces}\") to users;";
    EXPECT_NO_THROW({
        memdb::core::ParsedQuery pq_insert = parser.parse(insert_query);
        db.insert_row(pq_insert.table_name, *pq_insert.insert_values);
    });
}

TEST(InsertTest, InsertNullValues) {
    memdb::core::Database db;
    memdb::core::QueryParser parser;
    parser.set_database(&db);
    
    std::string create_query = "create table users (id : int32, name: string[32], email: string[50] = \"\");";
    memdb::core::ParsedQuery pq_create = parser.parse(create_query);
    db.create_table(pq_create.table_name, pq_create.columns);
    
    std::string insert_query = "insert (2, \"Grace\") to users;";
    EXPECT_NO_THROW({
        memdb::core::ParsedQuery pq_insert = parser.parse(insert_query);
        db.insert_row(pq_insert.table_name, *pq_insert.insert_values);
    });

    auto table = db.get_table("users");
    ASSERT_EQ(table->get_all_rows().size(), 1);
    const auto& row = table->get_row(1); 

    auto email_value = row.get_value(2);
    ASSERT_TRUE(email_value.has_value());
    EXPECT_EQ(email_value->get_string(), ""); 
}

TEST(InsertTest, NamedColumnInsert) {
    memdb::core::Database db;
    memdb::core::QueryParser parser;
    parser.set_database(&db);
    
    std::string create_query = "create table users ({key, autoincrement} id : int32, login: string[32], password_hash: bytes[8]);";
    memdb::core::ParsedQuery pq_create = parser.parse(create_query);
    db.create_table(pq_create.table_name, pq_create.columns);
    
    std::string insert_query = "insert (login = \"vasya\", password_hash = 0xdeadbeef) to users;";
    EXPECT_NO_THROW({
        memdb::core::ParsedQuery pq_insert = parser.parse(insert_query);
        db.insert_row(pq_insert.table_name, *pq_insert.insert_values);
    });
}

TEST(InsertTest, MultilineInsert) {
    memdb::core::Database db;
    memdb::core::QueryParser parser;
    parser.set_database(&db);
    
    std::string create_query = "create table users ({key, autoincrement} id : int32, login: string[32], is_admin: bool);";
    memdb::core::ParsedQuery pq_create = parser.parse(create_query);
    db.create_table(pq_create.table_name, pq_create.columns);
    
    std::string insert_query = R"(insert (
        login = "admin",
        is_admin = true
    ) to users;)";
    
    EXPECT_NO_THROW({
        memdb::core::ParsedQuery pq_insert = parser.parse(insert_query);
        db.insert_row(pq_insert.table_name, *pq_insert.insert_values);
    });

    insert_query = R"(insert (
        ,
        "admin",
        true
    ) to users;)";
    
    EXPECT_NO_THROW({
        memdb::core::ParsedQuery pq_insert = parser.parse(insert_query);
        db.insert_row(pq_insert.table_name, *pq_insert.insert_values);
    });
}

TEST(InsertTest, EmptyValuesForDefaults) {
    memdb::core::Database db;
    memdb::core::QueryParser parser;
    parser.set_database(&db);
    
    std::string create_query = "create table users ({key, autoincrement} id : int32, login: string[32], is_admin: bool = false);";
    memdb::core::ParsedQuery pq_create = parser.parse(create_query);
    db.create_table(pq_create.table_name, pq_create.columns);
    
    std::string insert_query = "insert (, \"bob\", ) to users;";
    EXPECT_NO_THROW({
        memdb::core::ParsedQuery pq_insert = parser.parse(insert_query);
        db.insert_row(pq_insert.table_name, *pq_insert.insert_values);
    });
    
    auto table = db.get_table("users");
    const auto& row = table->get_row(1);
    EXPECT_EQ(row.get_value(1)->get_string(), "bob");
    EXPECT_EQ(row.get_value(2)->get_bool(), false);
}

TEST(InsertTest, DuplicateColumnNamesInNamedInsert) {
    memdb::core::Database db;
    memdb::core::QueryParser parser;
    parser.set_database(&db);
    
    std::string create_query = "create table users ({key, autoincrement} id : int32, username: string[32], email: string[64]);";
    memdb::core::ParsedQuery pq_create = parser.parse(create_query);
    db.create_table(pq_create.table_name, pq_create.columns);
    
    std::string insert_query = "insert (username = \"john_doe\", email = \"john@example.com\", username = \"johnny\") to users;";
    try {
        memdb::core::ParsedQuery pq_insert = parser.parse(insert_query);
        db.insert_row(pq_insert.table_name, *pq_insert.insert_values);
        FAIL() << "Expected exception for duplicate column names in insert.";
    } catch (const std::invalid_argument& e) {
        EXPECT_THAT(e.what(), testing::HasSubstr("Duplicate column name: username"));
    }
}

TEST(InsertTest, InsertWithInvalidColumnNames) {
    memdb::core::Database db;
    memdb::core::QueryParser parser;
    parser.set_database(&db);
    
    std::string create_query = "create table products ({key, autoincrement} id : int32, name: string[50], price: int32);";
    memdb::core::ParsedQuery pq_create = parser.parse(create_query);
    db.create_table(pq_create.table_name, pq_create.columns);
    
    std::string insert_query = "insert (name = \"Laptop\", cost = 1500) to products;";
    try {
        memdb::core::ParsedQuery pq_insert = parser.parse(insert_query);
        db.insert_row(pq_insert.table_name, *pq_insert.insert_values);
        FAIL() << "Expected exception for invalid column name in insert.";
    } catch (const std::invalid_argument& e) {
        EXPECT_THAT(e.what(), testing::HasSubstr("Column not found: cost"));
    }
}

TEST(InsertTest, InsertWithEscapedCharacters) {
    memdb::core::Database db;
    memdb::core::QueryParser parser;
    parser.set_database(&db);
    
    std::string create_query = "create table messages ({key, autoincrement} id : int32, content: string[100]);";
    memdb::core::ParsedQuery pq_create = parser.parse(create_query);
    db.create_table(pq_create.table_name, pq_create.columns);
    
    std::string insert_query = "insert (, \"Hello, \\\"World\\\"!\\nNew Line\") to messages;";
    EXPECT_NO_THROW({
        memdb::core::ParsedQuery pq_insert = parser.parse(insert_query);
        db.insert_row(pq_insert.table_name, *pq_insert.insert_values);
    });
    
    auto table = db.get_table("messages");
    ASSERT_EQ(table->get_all_rows().size(), 1);
    const auto& row = table->get_row(1);
    
    EXPECT_EQ(row.get_value(1)->get_string(), "Hello, \"World\"!\nNew Line");
}

TEST(InsertTest, InsertMinMaxInt32) {
    memdb::core::Database db;
    memdb::core::QueryParser parser;
    parser.set_database(&db);
    
    std::string create_query = "create table numbers (id : int32, value: int32);";
    memdb::core::ParsedQuery pq_create = parser.parse(create_query);
    db.create_table(pq_create.table_name, pq_create.columns);
    
    std::string insert_query_min = "insert (1, -2147483648) to numbers;";
    std::string insert_query_max = "insert (2, 2147483647) to numbers;";
    
    EXPECT_NO_THROW({
        memdb::core::ParsedQuery pq_insert_min = parser.parse(insert_query_min);
        db.insert_row(pq_insert_min.table_name, *pq_insert_min.insert_values);
        
        memdb::core::ParsedQuery pq_insert_max = parser.parse(insert_query_max);
        db.insert_row(pq_insert_max.table_name, *pq_insert_max.insert_values);
    });
    
    auto table = db.get_table("numbers");
    ASSERT_EQ(table->get_all_rows().size(), 2);
    
    const auto& row_min = table->get_row(1);
    const auto& row_max = table->get_row(2);
    
    EXPECT_EQ(row_min.get_value(1)->get_int(), -2147483648);
    EXPECT_EQ(row_max.get_value(1)->get_int(), 2147483647);
}

TEST(InsertTest, InsertEmptyStringsAndBytes) {
    memdb::core::Database db;
    memdb::core::QueryParser parser;
    parser.set_database(&db);
    
    std::string create_query = "create table test (id : int32, name: string[10], data: bytes[4]);";
    memdb::core::ParsedQuery pq_create = parser.parse(create_query);
    db.create_table(pq_create.table_name, pq_create.columns);
    
    std::string insert_query = "insert (1, \"\", 0x0000) to test;";
    EXPECT_NO_THROW({
        memdb::core::ParsedQuery pq_insert = parser.parse(insert_query);
        db.insert_row(pq_insert.table_name, *pq_insert.insert_values);
    });
    
    auto table = db.get_table("test");
    ASSERT_EQ(table->get_all_rows().size(), 1);
    
    const auto& row = table->get_row(1);
    EXPECT_EQ(row.get_value(2)->get_string(), "");
    EXPECT_EQ(row.get_value(3)->get_bytes(), std::vector<uint8_t>({0x00, 0x00}));
}

```
```
kirill@kirill-BRN-FXX:~/Desktop/memdb_project2/memdb_project/build$ ./run_tests 
[==========] Running 48 tests from 2 test suites.
[----------] Global test environment set-up.
[----------] 27 tests from CreateTableTest
[ RUN      ] CreateTableTest.SuccessfulCreation
[       OK ] CreateTableTest.SuccessfulCreation (0 ms)
[ RUN      ] CreateTableTest.DuplicateColumnNames
[       OK ] CreateTableTest.DuplicateColumnNames (0 ms)
[ RUN      ] CreateTableTest.UnknownColumnType
[       OK ] CreateTableTest.UnknownColumnType (0 ms)
[ RUN      ] CreateTableTest.EmptyTableName
[       OK ] CreateTableTest.EmptyTableName (0 ms)
[ RUN      ] CreateTableTest.CreateTableWithNoColumns
/home/kirill/Desktop/memdb_project2/memdb_project/tests/test_core/TestCreateTable.cpp:83: Failure
Failed
Expected exception for creating table with no columns.

[  FAILED  ] CreateTableTest.CreateTableWithNoColumns (0 ms)
[ RUN      ] CreateTableTest.InvalidColumnAttributes
[       OK ] CreateTableTest.InvalidColumnAttributes (0 ms)
[ RUN      ] CreateTableTest.UnbalancedParentheses
[       OK ] CreateTableTest.UnbalancedParentheses (0 ms)
[ RUN      ] CreateTableTest.MissingColon
[       OK ] CreateTableTest.MissingColon (0 ms)
[ RUN      ] CreateTableTest.InvalidDefaultValue
[       OK ] CreateTableTest.InvalidDefaultValue (0 ms)
[ RUN      ] CreateTableTest.MultipleTablesWithAttributes
[       OK ] CreateTableTest.MultipleTablesWithAttributes (1 ms)
[ RUN      ] CreateTableTest.VariousDataTypes
[       OK ] CreateTableTest.VariousDataTypes (0 ms)
[ RUN      ] CreateTableTest.CaseInsensitiveKeywords
[       OK ] CreateTableTest.CaseInsensitiveKeywords (0 ms)
[ RUN      ] CreateTableTest.ColumnsWithoutAttributes
[       OK ] CreateTableTest.ColumnsWithoutAttributes (0 ms)
[ RUN      ] CreateTableTest.ColumnsWithBracketsInString
[       OK ] CreateTableTest.ColumnsWithBracketsInString (0 ms)
[ RUN      ] CreateTableTest.MissingAttributes
[       OK ] CreateTableTest.MissingAttributes (0 ms)
[ RUN      ] CreateTableTest.DefaultValuesVariousTypes
[       OK ] CreateTableTest.DefaultValuesVariousTypes (0 ms)
[ RUN      ] CreateTableTest.StringAndBytesSizes
[       OK ] CreateTableTest.StringAndBytesSizes (0 ms)
[ RUN      ] CreateTableTest.WhitespaceVariations
[       OK ] CreateTableTest.WhitespaceVariations (0 ms)
[ RUN      ] CreateTableTest.EmptyAttributeList
[       OK ] CreateTableTest.EmptyAttributeList (0 ms)
[ RUN      ] CreateTableTest.MissingDefaultValue
[       OK ] CreateTableTest.MissingDefaultValue (0 ms)
[ RUN      ] CreateTableTest.InvalidCharactersInNames
[       OK ] CreateTableTest.InvalidCharactersInNames (0 ms)
[ RUN      ] CreateTableTest.CaseSensitivityTableNames
[       OK ] CreateTableTest.CaseSensitivityTableNames (0 ms)
[ RUN      ] CreateTableTest.ReservedKeywordsAsTableNames
[       OK ] CreateTableTest.ReservedKeywordsAsTableNames (0 ms)
[ RUN      ] CreateTableTest.ReservedKeywordAsColumnName
[       OK ] CreateTableTest.ReservedKeywordAsColumnName (0 ms)
[ RUN      ] CreateTableTest.TooLongStringPassed
[       OK ] CreateTableTest.TooLongStringPassed (0 ms)
[ RUN      ] CreateTableTest.TooLongBytesPassed
[       OK ] CreateTableTest.TooLongBytesPassed (0 ms)
[ RUN      ] CreateTableTest.CreateTableWithMixedAttributes
[       OK ] CreateTableTest.CreateTableWithMixedAttributes (0 ms)
[----------] 27 tests from CreateTableTest (11 ms total)

[----------] 21 tests from InsertTest
[ RUN      ] InsertTest.SuccessfulInsert
[       OK ] InsertTest.SuccessfulInsert (1 ms)
[ RUN      ] InsertTest.AutoIncrementedID
[       OK ] InsertTest.AutoIncrementedID (1 ms)
[ RUN      ] InsertTest.InsertWithUniqueConstraint
[       OK ] InsertTest.InsertWithUniqueConstraint (2 ms)
[ RUN      ] InsertTest.StringExceedsSize
[       OK ] InsertTest.StringExceedsSize (1 ms)
[ RUN      ] InsertTest.BytesExceedsSize
[       OK ] InsertTest.BytesExceedsSize (0 ms)
[ RUN      ] InsertTest.MissingValues
[       OK ] InsertTest.MissingValues (0 ms)
[ RUN      ] InsertTest.ExtraValues
[       OK ] InsertTest.ExtraValues (0 ms)
[ RUN      ] InsertTest.InvalidDataTypes
[       OK ] InsertTest.InvalidDataTypes (0 ms)
[ RUN      ] InsertTest.ReservedKeywordAsValue
[       OK ] InsertTest.ReservedKeywordAsValue (0 ms)
[ RUN      ] InsertTest.InsertIntoNonExistentTable
[       OK ] InsertTest.InsertIntoNonExistentTable (0 ms)
[ RUN      ] InsertTest.InsertWithDefaultValues
[       OK ] InsertTest.InsertWithDefaultValues (0 ms)
[ RUN      ] InsertTest.InsertWithSpecialCharacters
[       OK ] InsertTest.InsertWithSpecialCharacters (0 ms)
[ RUN      ] InsertTest.InsertNullValues
[       OK ] InsertTest.InsertNullValues (0 ms)
[ RUN      ] InsertTest.NamedColumnInsert
[       OK ] InsertTest.NamedColumnInsert (1 ms)
[ RUN      ] InsertTest.MultilineInsert
[       OK ] InsertTest.MultilineInsert (1 ms)
[ RUN      ] InsertTest.EmptyValuesForDefaults
[       OK ] InsertTest.EmptyValuesForDefaults (0 ms)
[ RUN      ] InsertTest.DuplicateColumnNamesInNamedInsert
[       OK ] InsertTest.DuplicateColumnNamesInNamedInsert (0 ms)
[ RUN      ] InsertTest.InsertWithInvalidColumnNames
[       OK ] InsertTest.InsertWithInvalidColumnNames (0 ms)
[ RUN      ] InsertTest.InsertWithEscapedCharacters
[       OK ] InsertTest.InsertWithEscapedCharacters (0 ms)
[ RUN      ] InsertTest.InsertMinMaxInt32
[       OK ] InsertTest.InsertMinMaxInt32 (1 ms)
[ RUN      ] InsertTest.InsertEmptyStringsAndBytes
/home/kirill/Desktop/memdb_project2/memdb_project/tests/test_core/TestInsert.cpp:437: Failure
Expected: { memdb::core::ParsedQuery pq_insert = parser.parse(insert_query); db.insert_row(pq_insert.table_name, *pq_insert.insert_values); } doesn't throw an exception.
  Actual: it throws std::invalid_argument with description "Missing value for column: name".

/home/kirill/Desktop/memdb_project2/memdb_project/tests/test_core/TestInsert.cpp:443: Failure
Expected equality of these values:
  table->get_all_rows().size()
    Which is: 0
  1

[  FAILED  ] InsertTest.InsertEmptyStringsAndBytes (1 ms)
[----------] 21 tests from InsertTest (21 ms total)

[----------] Global test environment tear-down
[==========] 48 tests from 2 test suites ran. (33 ms total)
[  PASSED  ] 46 tests.
[  FAILED  ] 2 tests, listed below:
[  FAILED  ] CreateTableTest.CreateTableWithNoColumns
[  FAILED  ] InsertTest.InsertEmptyStringsAndBytes

 2 FAILED TESTS
 ```