Skip to content

Implement n_distinct() #145

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Tracked by #205
thisisnic opened this issue Jun 7, 2022 · 1 comment · Fixed by #244
Closed
Tracked by #205

Implement n_distinct() #145

thisisnic opened this issue Jun 7, 2022 · 1 comment · Fixed by #244

Comments

@thisisnic
Copy link
Contributor

No description provided.

@thisisnic
Copy link
Contributor Author

thisisnic commented Jan 23, 2023

In DuckDB, this appears to be implemented thus:

> duckdb_get_substrait("SELECT COUNT(DISTINCT hp) AS cd FROM mtcars", list(mtcars = mtcars))
message of type 'substrait.Plan' with 2 fields set
extensions {
  extension_function {
    function_anchor: 1
    name: "count"
  }
}
relations {
  root {
    input {
      project {
        input {
          aggregate {
            input {
              read {
                base_schema {
                  names: "mpg"
                  names: "cyl"
                  names: "disp"
                  names: "hp"
                  names: "drat"
                  names: "wt"
                  names: "qsec"
                  names: "vs"
                  names: "am"
                  names: "gear"
                  names: "carb"
                  struct {
                    types {
                      fp64 {
                        nullability: NULLABILITY_NULLABLE
                      }
                    }
                    types {
                      fp64 {
                        nullability: NULLABILITY_NULLABLE
                      }
                    }
                    types {
                      fp64 {
                        nullability: NULLABILITY_NULLABLE
                      }
                    }
                    types {
                      fp64 {
                        nullability: NULLABILITY_NULLABLE
                      }
                    }
                    types {
                      fp64 {
                        nullability: NULLABILITY_NULLABLE
                      }
                    }
                    types {
                      fp64 {
                        nullability: NULLABILITY_NULLABLE
                      }
                    }
                    types {
                      fp64 {
                        nullability: NULLABILITY_NULLABLE
                      }
                    }
                    types {
                      fp64 {
                        nullability: NULLABILITY_NULLABLE
                      }
                    }
                    types {
                      fp64 {
                        nullability: NULLABILITY_NULLABLE
                      }
                    }
                    types {
                      fp64 {
                        nullability: NULLABILITY_NULLABLE
                      }
                    }
                    types {
                      fp64 {
                        nullability: NULLABILITY_NULLABLE
                      }
                    }
                    nullability: NULLABILITY_REQUIRED
                  }
                }
                projection {
                  select {
                    struct_items {
                      field: 3
                    }
                  }
                  maintain_singular_struct: true
                }
                named_table {
                  names: "mtcars"
                }
              }
            }
            groupings {
            }
            measures {
              measure {
                function_reference: 1
                output_type {
                  i64 {
                    nullability: NULLABILITY_NULLABLE
                  }
                }
                arguments {
                  value {
                    selection {
                      direct_reference {
                        struct_field {
                        }
                      }
                      root_reference {
                      }
                    }
                  }
                }
              }
            }
          }
        }
        expressions {
          selection {
            direct_reference {
              struct_field {
              }
            }
            root_reference {
            }
          }
        }
      }
    }
    names: "cd"
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant