{
  "crossfield": 1,
  "name": "numbers",
  "id": "test/semantic_overloads",
  "bindings": {
    "builtin": {
      "catalog": "system",
      "provider_id": "duckdb",
      "instance_id": "system"
    }
  },
  "invocations": {
    "version": 1,
    "sources": {
      "range_source": {
        "id": "test/range_source",
        "dataset": {
          "name": "numbers",
          "id": "test/numbers",
          "grain": [
            "number"
          ],
          "fields": {
            "number": {
              "source_column": "range",
              "dimension": true
            }
          }
        },
        "binding_key": "builtin",
        "provider_id": "duckdb",
        "instance_id": "system",
        "function": {
          "schema": "main",
          "name": "range",
          "arguments": [
            {
              "id": "stop",
              "physical_name": "stop",
              "position": 0,
              "type": "BIGINT",
              "nullable": false,
              "binding": "scalar_or_driver"
            }
          ]
        },
        "profile": "row_map_sync_v1",
        "result_columns": [
          {
            "name": "range",
            "type": "BIGINT",
            "nullable": false
          }
        ],
        "assertions": {
          "authority": "crossfield.fixture.admin",
          "read_only": true,
          "execution_safe_bind": true,
          "input_from_args": true,
          "independent_rows": true,
          "requires_optimizer": false,
          "async": false
        },
        "consistency": {
          "kind": "live_explicit",
          "authority": "crossfield.fixture.admin"
        },
        "settings": [],
        "required_secrets": [],
        "transport": {
          "finite_timeout_ms": 10000,
          "cooperative_cancellation": true,
          "authority": "crossfield.fixture.provider"
        }
      },
      "interval_source": {
        "id": "test/overload_interval_source",
        "dataset": "numbers",
        "binding_key": "builtin",
        "provider_id": "duckdb",
        "instance_id": "system",
        "function": {
          "schema": "main",
          "name": "range",
          "arguments": [
            {
              "id": "start",
              "physical_name": "start",
              "position": 0,
              "type": "BIGINT",
              "nullable": false,
              "binding": "scalar_or_driver"
            },
            {
              "id": "stop",
              "physical_name": "stop",
              "position": 1,
              "type": "BIGINT",
              "nullable": false,
              "binding": "scalar_or_driver"
            }
          ]
        },
        "profile": "row_map_sync_v1",
        "result_columns": [
          {
            "name": "range",
            "type": "BIGINT",
            "nullable": false
          }
        ],
        "assertions": {
          "authority": "crossfield.fixture.admin",
          "read_only": true,
          "execution_safe_bind": true,
          "input_from_args": true,
          "independent_rows": true,
          "requires_optimizer": false,
          "async": false
        },
        "consistency": {
          "kind": "live_explicit",
          "authority": "crossfield.fixture.admin"
        },
        "settings": [],
        "required_secrets": [],
        "transport": {
          "finite_timeout_ms": 10000,
          "cooperative_cancellation": true,
          "authority": "crossfield.fixture.provider"
        }
      },
      "candidate_source": {
        "id": "test/overload_candidate_source",
        "dataset": {
          "name": "candidates",
          "id": "test/overload_candidates",
          "grain": [
            "candidate"
          ],
          "fields": {
            "candidate": {
              "source_column": "range",
              "dimension": true
            },
            "next_candidate": {
              "expression": "candidates.candidate + 1",
              "type": "BIGINT",
              "dimension": true
            }
          }
        },
        "binding_key": "builtin",
        "provider_id": "duckdb",
        "instance_id": "system",
        "function": {
          "schema": "main",
          "name": "range",
          "arguments": [
            {
              "id": "stop",
              "physical_name": "stop",
              "position": 0,
              "type": "BIGINT",
              "nullable": false,
              "binding": "scalar_or_driver"
            }
          ]
        },
        "profile": "row_map_sync_v1",
        "result_columns": [
          {
            "name": "range",
            "type": "BIGINT",
            "nullable": false
          }
        ],
        "assertions": {
          "authority": "crossfield.fixture.admin",
          "read_only": true,
          "execution_safe_bind": true,
          "input_from_args": true,
          "independent_rows": true,
          "requires_optimizer": false,
          "async": false
        },
        "consistency": {
          "kind": "live_explicit",
          "authority": "crossfield.fixture.admin"
        },
        "settings": [],
        "required_secrets": [],
        "transport": {
          "finite_timeout_ms": 10000,
          "cooperative_cancellation": true,
          "authority": "crossfield.fixture.provider"
        }
      }
    },
    "input_contracts": {
      "bounds": {
        "id": "test/range_bounds_input",
        "dataset": {
          "name": "bounds",
          "id": "test/range_bounds",
          "grain": [
            "stop"
          ],
          "fields": {
            "stop": {
              "source_column": "stop",
              "dimension": true
            }
          }
        },
        "columns": [
          {
            "name": "stop",
            "type": "BIGINT",
            "nullable": false
          }
        ]
      },
      "interval_bounds": {
        "id": "test/interval_bounds_input",
        "dataset": {
          "name": "interval_bounds",
          "id": "test/interval_bounds",
          "grain": [
            "start",
            "stop"
          ],
          "fields": {
            "start": {
              "source_column": "start",
              "dimension": true
            },
            "stop": {
              "source_column": "stop",
              "dimension": true
            }
          }
        },
        "columns": [
          {
            "name": "start",
            "type": "BIGINT",
            "nullable": false
          },
          {
            "name": "stop",
            "type": "BIGINT",
            "nullable": false
          }
        ]
      },
      "text_bounds": {
        "id": "test/text_bounds_input",
        "dataset": {
          "name": "text_bounds",
          "id": "test/text_bounds",
          "grain": [
            "extra"
          ],
          "fields": {
            "label": {
              "source_column": "label",
              "dimension": true
            },
            "extra": {
              "source_column": "extra",
              "dimension": true
            },
            "text_stop": {
              "expression": "COALESCE(LENGTH(text_bounds.label), 0) + text_bounds.extra",
              "type": "BIGINT",
              "dimension": true
            }
          }
        },
        "columns": [
          {
            "name": "label",
            "type": "VARCHAR",
            "nullable": true
          },
          {
            "name": "extra",
            "type": "BIGINT",
            "nullable": false
          }
        ]
      }
    }
  },
  "metrics": {
    "number_count": {
      "expression": "COUNT(*)",
      "type": "BIGINT"
    },
    "number_sum": {
      "expression": "SUM(numbers.number)",
      "type": "HUGEINT"
    }
  },
  "policy": {
    "policy_version": 1,
    "metrics": [
      "number_count",
      "number_sum"
    ],
    "dimensions": [
      "numbers.number",
      "bounds.stop",
      "interval_bounds.start",
      "interval_bounds.stop",
      "text_bounds.label",
      "text_bounds.extra",
      "text_bounds.text_stop",
      "candidates.candidate",
      "candidates.next_candidate"
    ],
    "filter_dimensions": [
      "numbers.number",
      "bounds.stop",
      "interval_bounds.start",
      "interval_bounds.stop",
      "text_bounds.label",
      "text_bounds.extra",
      "text_bounds.text_stop",
      "candidates.candidate",
      "candidates.next_candidate"
    ],
    "detail_fields": [
      "numbers.number",
      "bounds.stop",
      "interval_bounds.start",
      "interval_bounds.stop",
      "text_bounds.label",
      "text_bounds.extra",
      "text_bounds.text_stop",
      "candidates.candidate",
      "candidates.next_candidate"
    ],
    "invocation_sources": [
      "range_source",
      "interval_source",
      "candidate_source"
    ],
    "metric_semantics": {
      "number_count": {
        "dataset": "numbers",
        "additivity": "additive"
      },
      "number_sum": {
        "dataset": "numbers",
        "additivity": "additive"
      }
    },
    "driving_grain_reduction": [
      "range_source",
      "interval_source",
      "candidate_source"
    ],
    "field_semantics": {
      "numbers.number": {
        "sql_name": "number",
        "shared_dimension": "test.overload.number.v1"
      },
      "bounds.stop": {
        "sql_name": "stop"
      },
      "interval_bounds.start": {
        "sql_name": "interval_start"
      },
      "interval_bounds.stop": {
        "sql_name": "interval_stop"
      }
    },
    "allow_semantic_joins": true
  },
  "semantic_query": {
    "overloads": [
      {
        "id": "up_to",
        "comment": "Integers from zero to the exclusive bound.",
        "parameters": [
          {
            "name": "stop",
            "type": "BIGINT",
            "calling": "positional_or_named",
            "nullable": false,
            "minimum": 0,
            "example": 5
          }
        ],
        "request": {
          "version": 1,
          "inputs": {
            "selection": {
              "definition": "bounds",
              "rows": [
                [
                  {
                    "parameter": "stop"
                  }
                ]
              ]
            }
          },
          "source_bindings": {
            "numbers": {
              "driver": {
                "input": "selection"
              },
              "arguments": {
                "stop": {
                  "member": "bounds.stop"
                }
              },
              "allow_driving_grain_reduction": true
            }
          }
        }
      },
      {
        "id": "interval",
        "comment": "Integers in the half-open interval.",
        "parameters": [
          {
            "name": "start",
            "type": "BIGINT",
            "calling": "positional_or_named",
            "nullable": false,
            "example": 2
          },
          {
            "name": "stop",
            "type": "BIGINT",
            "calling": "positional_or_named",
            "nullable": false,
            "example": 5
          }
        ],
        "request": {
          "version": 1,
          "inputs": {
            "selection": {
              "definition": "interval_bounds",
              "rows": [
                [
                  {
                    "parameter": "start"
                  },
                  {
                    "parameter": "stop"
                  }
                ]
              ]
            }
          },
          "source_bindings": {
            "numbers": {
              "driver": {
                "input": "selection"
              },
              "arguments": {
                "start": {
                  "member": "interval_bounds.start"
                },
                "stop": {
                  "member": "interval_bounds.stop"
                }
              },
              "allow_driving_grain_reduction": true
            }
          }
        },
        "source_overrides": {
          "numbers": "interval_source"
        }
      },
      {
        "id": "pipeline",
        "comment": "Generate candidates, exclude zero, then fetch one approved integer per candidate.",
        "parameters": [
          {
            "name": "seed",
            "type": "BIGINT",
            "calling": "keyword_only",
            "nullable": false,
            "minimum": 0,
            "example": 4
          }
        ],
        "request": {
          "version": 1,
          "inputs": {
            "selection": {
              "definition": "bounds",
              "rows": [
                [
                  {
                    "parameter": "seed"
                  }
                ]
              ]
            }
          },
          "source_bindings": {
            "candidates": {
              "driver": {
                "input": "selection"
              },
              "arguments": {
                "stop": {
                  "member": "bounds.stop"
                }
              },
              "allow_driving_grain_reduction": true
            },
            "numbers": {
              "driver": {
                "stage": "candidates",
                "filter": {
                  "op": "gte",
                  "member": "candidates.candidate",
                  "values": [
                    1
                  ]
                }
              },
              "arguments": {
                "start": {
                  "member": "candidates.candidate"
                },
                "stop": {
                  "member": "candidates.next_candidate"
                }
              },
              "allow_driving_grain_reduction": true
            }
          }
        },
        "source_overrides": {
          "numbers": "interval_source"
        }
      },
      {
        "id": "collection",
        "parameters": [
          {
            "name": "bounds",
            "type": "STRUCT(stop BIGINT)[]",
            "calling": "keyword_only",
            "nullable": false,
            "example": [
              {
                "stop": 2
              },
              {
                "stop": 3
              }
            ]
          }
        ],
        "request": {
          "version": 1,
          "inputs": {
            "selection": {
              "definition": "bounds",
              "rows_parameter": "bounds"
            }
          },
          "source_bindings": {
            "numbers": {
              "driver": {
                "input": "selection"
              },
              "arguments": {
                "stop": {
                  "member": "bounds.stop"
                }
              },
              "allow_driving_grain_reduction": true
            }
          }
        }
      },
      {
        "id": "text",
        "parameters": [
          {
            "name": "label",
            "type": "VARCHAR",
            "calling": "positional_or_named",
            "nullable": true,
            "non_empty": true,
            "example": "abc"
          },
          {
            "name": "extra",
            "type": "BIGINT",
            "calling": "keyword_only",
            "nullable": false,
            "default": 0,
            "minimum": 0
          }
        ],
        "request": {
          "version": 1,
          "inputs": {
            "selection": {
              "definition": "text_bounds",
              "rows": [
                [
                  {
                    "parameter": "label"
                  },
                  {
                    "parameter": "extra"
                  }
                ]
              ]
            }
          },
          "source_bindings": {
            "numbers": {
              "driver": {
                "input": "selection"
              },
              "arguments": {
                "stop": {
                  "member": "text_bounds.text_stop"
                }
              },
              "allow_driving_grain_reduction": true
            }
          }
        }
      }
    ]
  }
}
