378170 {
378171 switch (expr.GetExpressionClass()) {
378172 case ExpressionClass::CONSTANT: {
378173 auto &constant = expr.Cast<ConstantExpression>();
378174
378175 if (!constant.value.type().IsIntegral()) {
378176
378177
378178
378179 auto order_by_non_integer_literal =
378180 Settings::Get<OrderByNonIntegerLiteralSetting>(binders[0].
get().context);
378181 if (!order_by_non_integer_literal) {
378182 throw BinderException(expr,
378183 "%s non-integer literal has no effect.\n* SET "
378184 "order_by_non_integer_literal=true to allow this behavior.",
378185 query_component);
378186 }
378187 break;
378188 }
378189
378190 auto order_value = constant.value.GetValue<
int64_t>();
378191 return static_cast<idx_t>(order_value <= 0 ? NumericLimits<int64_t>::Maximum() : order_value - 1);
378192 }
378193 case ExpressionClass::COLUMN_REF: {
378194 auto &colref = expr.Cast<ColumnRefExpression>();
378195 if (!ExpressionBinder::IsPotentialAlias(colref)) {
378196 break;
378197 }
378198
378199 string alias_name = colref.column_names.back();
378200
378201 auto entry = bind_state.alias_map.find(alias_name);
378202 if (entry != bind_state.alias_map.end()) {
378203
378204 return entry->second;
378205 }
378206
378207 vector<idx_t> matching_columns;
378208 for (
idx_t i = 0; i < bind_state.original_expressions.size(); i++) {
378209 if (bind_state.original_expressions[i]->type != ExpressionType::COLUMN_REF) {
378210 continue;
378211 }
378212 auto &colref = bind_state.original_expressions[i]->Cast<ColumnRefExpression>();
378213 if (colref.HasAlias()) {
378214 continue;
378215 }
378216 if (colref.GetColumnName() == alias_name) {
378217 matching_columns.push_back(i);
378218 }
378219 }
378220 if (matching_columns.size() == 1) {
378221 return matching_columns[0];
378222 }
378223 break;
378224 }
378225 case ExpressionClass::POSITIONAL_REFERENCE: {
378226 auto &posref = expr.Cast<PositionalReferenceExpression>();
378227 return posref.index - 1;
378228 }
378229 default:
378230 break;
378231 }
378232 return optional_idx();
378233}
__host__ cudaTextureObject_t get() const noexcept
uint64_t idx_t
a saner size_t for loop indices etc
Definition duckdb.hpp:237