1//===----------------------------------------------------------------------===//
2// DuckDB
3//
4// duckdb/parser/expression/subquery_expression.hpp
5//
6//
7//===----------------------------------------------------------------------===//
8
9#pragma once
10
11#include "duckdb/common/enums/subquery_type.hpp"
12#include "duckdb/parser/parsed_expression.hpp"
13#include "duckdb/parser/query_node.hpp"
14
15namespace duckdb {
16
17//! Represents a subquery
18class SubqueryExpression : public ParsedExpression {
19public:
20 SubqueryExpression();
21
22 //! The actual subquery
23 unique_ptr<QueryNode> subquery;
24 //! The subquery type
25 SubqueryType subquery_type;
26 //! the child expression to compare with (in case of IN, ANY, ALL operators, empty for EXISTS queries and scalar
27 //! subquery)
28 unique_ptr<ParsedExpression> child;
29 //! The comparison type of the child expression with the subquery (in case of ANY, ALL operators), empty otherwise
30 ExpressionType comparison_type;
31
32public:
33 bool HasSubquery() const override {
34 return true;
35 }
36 bool IsScalar() const override {
37 return false;
38 }
39
40 string ToString() const override;
41
42 static bool Equals(const SubqueryExpression *a, const SubqueryExpression *b);
43
44 unique_ptr<ParsedExpression> Copy() const override;
45
46 void Serialize(Serializer &serializer) override;
47 static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, Deserializer &source);
48};
49} // namespace duckdb
50