kamcheungting-db commented on code in PR #1069:
URL: https://github.com/apache/iceberg-cpp/pull/1069#discussion_r4733417805


##########
src/iceberg/view/view_version.h:
##########
@@ -0,0 +1,121 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#pragma once
+
+/// \file iceberg/view_version.h
+/// A version of an Iceberg view.
+
+#include <cstdint>
+#include <optional>
+#include <string>
+#include <string_view>
+#include <unordered_map>
+#include <variant>
+#include <vector>
+
+#include "iceberg/iceberg_export.h"
+#include "iceberg/table_identifier.h"
+#include "iceberg/util/timepoint.h"
+
+namespace iceberg {
+
+/// \brief The SQL representation of a view version's definition.
+///
+/// Each SQL representation pairs a query with its engine dialect, such as
+/// "spark". Dialect strings are preserved verbatim and compared with ASCII
+/// case folding.
+struct ICEBERG_EXPORT SqlViewRepresentation {
+  /// The SQL SELECT statement that defines the view.
+  std::string sql;
+  /// The dialect of the SELECT statement, such as "spark" or "trino".
+  std::string dialect;
+
+  /// \brief Compare two SQL representations for equality.
+  friend bool operator==(const SqlViewRepresentation& lhs,
+                         const SqlViewRepresentation& rhs) = default;
+};
+
+/// \brief An opaque representation type this library does not interpret.
+///
+/// Unknown representations are preserved so that metadata round trips and
+/// property edits do not lose them. Definition changes that involve them are
+/// rejected instead of being partially rewritten.
+struct ICEBERG_EXPORT UnknownViewRepresentation {
+  /// The representation type identifier from the metadata, such as "cypher".
+  std::string type;
+
+  /// \brief Compare two unknown representations for equality.
+  friend bool operator==(const UnknownViewRepresentation& lhs,
+                         const UnknownViewRepresentation& rhs) = default;
+};
+
+/// \brief A representation of a view version's definition: SQL or opaque.
+using ViewRepresentation = std::variant<SqlViewRepresentation, 
UnknownViewRepresentation>;
+
+/// \brief The type identifier of the SQL representation.
+inline constexpr std::string_view kSqlRepresentationType = "sql";
+
+/// \brief Get the SQL representation.
+///
+/// \return the SQL representation, or nullptr when the representation is not
+/// a SQL representation. The pointer remains valid until the representation
+/// is modified or destroyed.
+ICEBERG_EXPORT const SqlViewRepresentation* GetSql(const ViewRepresentation& 
repr);

Review Comment:
   Done.
   Deleted rvalue overloads for both helpers. Added compile-time checks 
covering temporary variants and implicit conversions from named alternatives.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to