Get the version of the compiler. This is determined by the first of: - An optional environment variable `PRQL_VERSION_OVERRIDE`; primarily useful for internal testing. - Note that this env var is checked on every call of this function. Without checking each read, we found some internal tests were flaky. If this caused any perf issues, we could adjust the tests that rely on versions to run in a mor
()
| 140 | /// - The version returned by `git describe --tags` |
| 141 | /// - The version in the cargo manifest |
| 142 | pub fn compiler_version() -> Version { |
| 143 | if let Ok(prql_version_override) = std::env::var("PRQL_VERSION_OVERRIDE") { |
| 144 | return Version::parse(&prql_version_override).unwrap_or_else(|e| { |
| 145 | panic!("Could not parse PRQL version {prql_version_override}\n{e}") |
| 146 | }); |
| 147 | }; |
| 148 | |
| 149 | static COMPILER_VERSION: OnceLock<Version> = OnceLock::new(); |
| 150 | COMPILER_VERSION |
| 151 | .get_or_init(|| { |
| 152 | if let Ok(prql_version_override) = std::env::var("PRQL_VERSION_OVERRIDE") { |
| 153 | return Version::parse(&prql_version_override).unwrap_or_else(|e| { |
| 154 | panic!("Could not parse PRQL version {prql_version_override}\n{e}") |
| 155 | }); |
| 156 | } |
| 157 | let git_version = env!("VERGEN_GIT_DESCRIBE"); |
| 158 | let cargo_version = env!("CARGO_PKG_VERSION"); |
| 159 | Version::parse(git_version) |
| 160 | .or_else(|e| { |
| 161 | log::info!("Could not parse git version number {git_version}\n{e}"); |
| 162 | Version::parse(cargo_version) |
| 163 | }) |
| 164 | .unwrap_or_else(|e| { |
| 165 | panic!("Could not parse prqlc version number {cargo_version}\n{e}") |
| 166 | }) |
| 167 | }) |
| 168 | .clone() |
| 169 | } |
| 170 | |
| 171 | /// Compile a PRQL string into a SQL string. |
| 172 | /// |
no test coverage detected