2019-05-17 04:08:03 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <Parsers/ASTConstraintDeclaration.h>
|
2020-12-10 23:56:57 +00:00
|
|
|
#include <Interpreters/ExpressionActions.h>
|
2021-03-04 12:11:43 +00:00
|
|
|
#include <Interpreters/TreeCNFConverter.h>
|
2021-04-03 12:12:45 +00:00
|
|
|
#include <Interpreters/ComparisonGraph.h>
|
2019-05-17 04:08:03 +00:00
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
2019-05-19 05:27:00 +00:00
|
|
|
using ConstraintsExpressions = std::vector<ExpressionActionsPtr>;
|
2019-05-17 04:08:03 +00:00
|
|
|
|
|
|
|
struct ConstraintsDescription
|
|
|
|
{
|
2020-05-12 11:47:59 +00:00
|
|
|
std::vector<ASTPtr> constraints;
|
2021-04-10 15:47:50 +00:00
|
|
|
//std::vector<CNFQuery> cnf_constraints;
|
2019-05-17 04:08:03 +00:00
|
|
|
|
2021-04-03 16:30:49 +00:00
|
|
|
// TODO: перенести преобразование в КНФ + get constraitns
|
2019-05-17 04:08:03 +00:00
|
|
|
ConstraintsDescription() = default;
|
|
|
|
|
|
|
|
bool empty() const { return constraints.empty(); }
|
|
|
|
String toString() const;
|
|
|
|
|
|
|
|
static ConstraintsDescription parse(const String & str);
|
2019-05-19 05:27:00 +00:00
|
|
|
|
2021-01-04 20:55:32 +00:00
|
|
|
enum class ConstraintType {
|
|
|
|
CHECK = 1,
|
|
|
|
ASSUME = 2,
|
|
|
|
ALWAYS_TRUE = CHECK | ASSUME,
|
|
|
|
ALL = CHECK | ASSUME,
|
|
|
|
};
|
|
|
|
|
|
|
|
ASTs filterConstraints(ConstraintType selection) const;
|
2021-04-03 12:12:45 +00:00
|
|
|
|
|
|
|
std::vector<std::vector<CNFQuery::AtomicFormula>> getConstraintData() const;
|
|
|
|
std::vector<CNFQuery::AtomicFormula> getAtomicConstraintData() const;
|
|
|
|
|
|
|
|
ComparisonGraph getGraph() const;
|
2021-01-03 15:02:00 +00:00
|
|
|
|
|
|
|
ConstraintsExpressions getExpressionsToCheck(const Context & context, const NamesAndTypesList & source_columns_) const;
|
2020-06-05 17:29:40 +00:00
|
|
|
|
|
|
|
ConstraintsDescription(const ConstraintsDescription & other);
|
|
|
|
ConstraintsDescription & operator=(const ConstraintsDescription & other);
|
2019-05-17 04:08:03 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|