MCPcopy Create free account
hub / github.com/apache/datafusion / as_generator

Method as_generator

datafusion/functions-table/src/generate_series.rs:244–338  ·  view source on GitHub ↗
(
        &self,
        batch_size: usize,
    )

Source from the content-addressed store, hash-verified

242 }
243
244 pub fn as_generator(
245 &self,
246 batch_size: usize,
247 ) -> Result<Arc<RwLock<dyn LazyBatchGenerator>>> {
248 let generator: Arc<RwLock<dyn LazyBatchGenerator>> = match &self.args {
249 GenSeriesArgs::ContainsNull { name } => Arc::new(RwLock::new(Empty { name })),
250 GenSeriesArgs::Int64Args {
251 start,
252 end,
253 step,
254 include_end,
255 name,
256 } => Arc::new(RwLock::new(GenericSeriesState {
257 schema: self.schema(),
258 start: *start,
259 end: *end,
260 step: *step,
261 current: *start,
262 batch_size,
263 include_end: *include_end,
264 name,
265 })),
266 GenSeriesArgs::TimestampArgs {
267 start,
268 end,
269 step,
270 tz,
271 include_end,
272 name,
273 } => {
274 let parsed_tz = tz
275 .as_ref()
276 .map(|s| Tz::from_str(s.as_ref()))
277 .transpose()
278 .map_err(|e| {
279 datafusion_common::internal_datafusion_err!(
280 "Failed to parse timezone: {e}"
281 )
282 })?
283 .unwrap_or_else(|| Tz::from_str("+00:00").unwrap());
284 Arc::new(RwLock::new(GenericSeriesState {
285 schema: self.schema(),
286 start: TimestampValue {
287 value: *start,
288 parsed_tz: Some(parsed_tz),
289 tz_str: tz.clone(),
290 },
291 end: TimestampValue {
292 value: *end,
293 parsed_tz: Some(parsed_tz),
294 tz_str: tz.clone(),
295 },
296 step: *step,
297 current: TimestampValue {
298 value: *start,
299 parsed_tz: Some(parsed_tz),
300 tz_str: tz.clone(),
301 },

Callers 2

scanMethod · 0.80

Calls 6

newFunction · 0.85
from_strFunction · 0.85
schemaMethod · 0.45
mapMethod · 0.45
as_refMethod · 0.45
cloneMethod · 0.45

Tested by

no test coverage detected