Add most functions to the Expr class so that they're chainable.

Aperta
#1,064 5 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
42/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
python
Ambito
data

Direzione di ricerca

Inizia dalla classe Expr e dal modulo functions citato nell'issue, quindi confronta i metodi Expr esistenti con le funzioni che accettano un'espressione come input. Aggiungi metodi concatenabili per le funzioni applicabili mantenendo l'API del modulo functions; il pattern mostrato col("id1").abs().alias("id1") e l'esempio con più input dovrebbero funzionare al termine.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

enhancement

Is your feature request related to a problem or challenge? Please describe what you are trying to do.
Instead of doing

df.select(
    F.abs(
        col("id1")
        )
    .alias("id1")
    )

It would be nicer to do

df.select(
    col("id1")
    .abs()
    .alias("id1")
    )

Describe the solution you'd like
This is already partly there, for example, alias is already in the Expr class. It would be a bit tedious but easy to add under class Expr, for example:

def abs(self) -> datafusion.Expr:
    """Return the absolute value of a given number.

    Returns:
    --------
    Expr
        A new expression representing the absolute value of the input expression.
    """
    return F.abs(self)

Describe alternatives you've considered
if it weren't for the type hinter, monkey patching.

Additional context
There will still be functions that don't make sense to chain off of a call to col such as when since it doesn't return an Expr. But, even functions that take multiple inputs can have this for instance col("a").atan2("b"). Additionally, this is completely backwards compatible since I'm not proposing eliminating the functions module.

Lingua principale
Python
Stelle
605
Fork
176
Merge medio
1g 23h
PR unite (30g)
8

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di apache/datafusion-python

Tutte le issue di apache/datafusion-python

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.