make-pythonic

Audits and refactors Apache DataFusion Python API to accept native types for literal arguments.

595|165|Updated Jul 20, 2022
One-click install
npx skills add https://github.com/apache/datafusion-python --skill make-pythonic
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: make-pythonic
Source: https://github.com/apache/datafusion-python/tree/main/.ai/skills/make-pythonic
Command: npx skills add https://github.com/apache/datafusion-python --skill make-pythonic

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill addresses the friction of using DataFusion's Python bindings by allowing native Python types for literal-like arguments, reducing boilerplate from lit() and col() wrappers, while preserving backward compatibility and aligning with Pythonic expectations.

Core Features & Use Cases

  • Audit and adjust function signatures in python/datafusion/functions.py to accept native Python types for literal arguments (e.g., Expr | int or Expr | float where appropriate), guided by upstream Rust constraints.
  • Identify literal-only argument patterns (per Technique 1/2) and implement coercion rules, update aliases, and refresh doctests to reflect the new calling conventions.
  • Provide real-world examples that demonstrate calling functions with native literals, such as split_part(col("a"), ",", 2), instead of lit(",") and lit(2).

Quick Start

Audit and refactor the python/datafusion/functions.py to accept native Python literals (e.g., 3, "x") and adjust coercion, aliases, and doctests.

Frequently Asked Questions about make-pythonic

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I use native Python types instead of lit() in DataFusion Python APIs?

Native Python types replace lit() wrappers in DataFusion Python APIs through signature coercion. Functions in python/datafusion/functions.py accept native literals like integers or strings directly, updating aliases and doctests to reflect Pythonic calling conventions while maintaining backward compatibility.

Can I pass raw Python literals like strings or integers directly to DataFusion expressions?

Passing raw Python literals directly to DataFusion expressions requires auditing function signatures against upstream Rust constraints. The API applies type coercion rules to accept native types for literal-only arguments, enabling calls like split_part(col("a"), ",", 2) without explicit wrappers.

Does refactoring DataFusion Python bindings for native types break existing code?

Refactoring DataFusion Python bindings for native types preserves backward compatibility. Existing lit() and col() wrappers continue functioning alongside new coercion rules, ensuring prior code remains operational while doctests refresh to demonstrate updated Pythonic calling conventions.

What's the best way to update doctests when adding Pythonic literal coercion to DataFusion?

Updating doctests for Pythonic literal coercion involves validating argument categories and consulting upstream Rust bindings for type constraints. Refresh test cases to demonstrate native literal usage, ensuring new coercion rules align with expected DataFusion API behavior.

Why does DataFusion require lit() for simple literal arguments in Python?

DataFusion historically required lit() for simple literal arguments due to Rust binding type constraints. Auditing function signatures identifies literal-only patterns, enabling automatic coercion of native Python types and reducing boilerplate while respecting upstream type limitations.

Are there limitations when coercing native Python types in DataFusion function signatures?

Coercing native Python types in DataFusion function signatures is limited by upstream Rust binding constraints. The API validates argument categories to determine eligible literal-only patterns, restricting automatic coercion where type safety or complex argument handling prevents direct native type acceptance.