|
1 | 1 | #include "yql_yt_ytflow_integration.h" |
| 2 | +#include "yql_yt_provider.h" |
2 | 3 | #include "yql_yt_table.h" |
3 | 4 |
|
4 | 5 | #include <yql/essentials/core/yql_expr_type_annotation.h> |
@@ -78,11 +79,18 @@ class TYtYtflowIntegration: public IYtflowIntegration { |
78 | 79 |
|
79 | 80 | auto cluster = TString(maybeWriteTable.Cast().DataSink().Cluster().Value()); |
80 | 81 | auto tableName = TString(TYtTableInfo::GetTableLabel(maybeWriteTable.Cast().Table())); |
81 | | - auto epoch = TEpochInfo::Parse(maybeWriteTable.Cast().Table().CommitEpoch().Ref()); |
| 82 | + auto commitEpoch = TEpochInfo::Parse(maybeWriteTable.Cast().Table().CommitEpoch().Ref()); |
82 | 83 |
|
83 | | - auto tableDesc = State_->TablesData->GetTable(cluster, tableName, epoch); |
| 84 | + auto tableDesc = State_->TablesData->GetTable( |
| 85 | + cluster, tableName, 0); |
84 | 86 |
|
85 | | - if (!tableDesc.Meta->IsDynamic) { |
| 87 | + auto commitTableDesc = State_->TablesData->GetTable( |
| 88 | + cluster, tableName, commitEpoch); |
| 89 | + |
| 90 | + if (!tableDesc.Meta->IsDynamic |
| 91 | + && tableDesc.Meta->DoesExist |
| 92 | + && !(commitTableDesc.Intents & TYtTableIntent::Override) |
| 93 | + ) { |
86 | 94 | AddMessage(ctx, "write to static table"); |
87 | 95 | return false; |
88 | 96 | } |
@@ -145,14 +153,30 @@ class TYtYtflowIntegration: public IYtflowIntegration { |
145 | 153 | auto maybeWriteTable = TMaybeNode<TYtWriteTable>(&sink); |
146 | 154 | YQL_ENSURE(maybeWriteTable); |
147 | 155 |
|
148 | | - auto table = maybeWriteTable.Cast().Table().Cast<TYtTable>(); |
| 156 | + NYtflow::NProto::TQYTSinkMessage sinkSettings; |
149 | 157 |
|
150 | | - auto* rowType = TYqlRowSpecInfo(table.RowSpec()).GetType(); |
| 158 | + { |
| 159 | + auto table = maybeWriteTable.Cast().Table().Cast<TYtTable>(); |
151 | 160 |
|
152 | | - NYtflow::NProto::TQYTSinkMessage sinkSettings; |
153 | | - sinkSettings.SetCluster(table.Cluster().StringValue()); |
154 | | - sinkSettings.SetPath(table.Name().StringValue()); |
155 | | - sinkSettings.SetRowType(NCommon::WriteTypeToYson(rowType)); |
| 161 | + sinkSettings.SetCluster(table.Cluster().StringValue()); |
| 162 | + sinkSettings.SetPath(table.Name().StringValue()); |
| 163 | + |
| 164 | + auto* rowType = maybeWriteTable.Cast().Content().Ref().GetTypeAnn() |
| 165 | + ->Cast<TListExprType>()->GetItemType(); |
| 166 | + |
| 167 | + sinkSettings.SetRowType(NCommon::WriteTypeToYson(rowType)); |
| 168 | + } |
| 169 | + |
| 170 | + { |
| 171 | + auto cluster = TString(maybeWriteTable.Cast().DataSink().Cluster().Value()); |
| 172 | + auto tableName = TString(TYtTableInfo::GetTableLabel(maybeWriteTable.Cast().Table())); |
| 173 | + |
| 174 | + auto tableDesc = State_->TablesData->GetTable( |
| 175 | + cluster, tableName, 0); |
| 176 | + |
| 177 | + sinkSettings.SetDoesExist(tableDesc.Meta->DoesExist); |
| 178 | + sinkSettings.SetTruncate(tableDesc.Intents & TYtTableIntent::Override); |
| 179 | + } |
156 | 180 |
|
157 | 181 | settings.PackFrom(sinkSettings); |
158 | 182 | } |
|
0 commit comments