#16418·dbt-core

[v2 Bug] `sort`-ing by positional attribute errors on v2 with `value is not a string`

Author: jeremyyeoCreated Sep 23, 2026Updated Oct 1, 2026
Labelstype:bugstatus:triageengine:v2source:customertriagebugv2

Is this a new bug in dbt v2.x compared to the latest version of dbt 1.x?

  • I believe this is a new bug in dbt v2.x
  • I have searched the existing issues and could not find a duplicate

Current Behavior

When sorting by position, we run into an error with v2. This works without issue in v1.

Expected Behavior

No issues.

Steps To Reproduce

sql
-- models/foo.sql
{% set x = [[1, "alice"], [3, "eve"], [2, "bob"], [4, "charlie"]] %}
{{ x | sort(attribute=0, reverse=False) }}
{{ x | sort(attribute=1, reverse=False) }}
bash
$ dbtf compile -s foo

       dbt 2.0.6
   Loading profiles.yml
    Failed model dbt_jyeo.foo (table) [1 of 1 in 0.00s]

=================================================================================================== Errors and Warnings ====================================================================================================
[error] [JinjaError (dbt1501)]: Failed to render SQL invalid operation: value is not a string
(in models/foo.sql:2:1)
  --> models/foo.sql:2:1

==================================================================================================== Execution Summary =====================================================================================================
Finished 'compile' with 1 error for target 'dev' [5.1s]
Processed: 1 model
Summary: 1 total | 1 error

$ dbt compile -s foo

21:35:05  Running with dbt=1.12.5
21:35:06  Registered adapter: bigquery=1.12.1
21:35:07  Found 207 models, 6 seeds, 200 data tests, 1 source, 561 macros
21:35:07  
21:35:07  Concurrency: 8 threads (target='dev')
21:35:07  
Compiled node 'foo' is:

[[1, 'alice'], [2, 'bob'], [3, 'eve'], [4, 'charlie']]
[[1, 'alice'], [2, 'bob'], [4, 'charlie'], [3, 'eve']]

Relevant log output

bash

Environment

markdown
- OS: macOS
- CPU: ARM
- dbt distribution and version: 2.0.6

Which database adapter are you using?

bigquery

Is this a discrepancy vs. dbt 1.x?

  • Yes — this works in dbt 1.x but not in dbt v2.x

Additional Context

No response