Comments (3)
thank you @bobcolner,
Would you like to help us with the documentation?
@btseytlin can show you the ropes of whats supported from SQL.
from dfsql.
@bobcolner Thanks!
Here's the currently supported list of functions:
OPERATIONS = (
And, Or, Not,
Equals, NotEquals, Greater, GreaterEqual, Less, LessEqual, Is, IsNot,
Plus, Minus, Multiply, Divide, Modulo, Power,
StringConcat, StringLower, StringUpper, Like,
In,
)
AGGREGATE_FUNCTIONS = (
Sum, Mean, Count, CountDistinct,
)
You can also make your own functions, similar to how you can do pd.DataFrame().apply(my_function)
or pd.DataFrame().agg({column: my_function})
.
E.g.:
def custom(x):
return x + '_custom_addition'
data_source.register_function('custom', custom)
sql = "SELECT custom(\"a\")"
query_result = data_source.query(sql)
assert query_result == 'a_custom_addition'
Or alternatively, you can pass custom functions to sql_query
:
from dfsql import sql_query
sql_query('SELECT magic_function(column1) FROM df', df=df, custom_functions={'magic_function': lambda x: x*x})
See these tests for examples:
https://github.com/mindsdb/dfsql/blob/stable/tests/test_data_sources/test_file_data_source.py#L342
https://github.com/mindsdb/dfsql/blob/stable/tests/test_data_sources/test_file_data_source.py#L712
from dfsql.
thanks!
from dfsql.
Related Issues (15)
- Build a license-inclusive dependency graph
- Table alias and groupby produces wrong output HOT 1
- dfsql.exceptions.dfsqlException: Table from_tables found in from_tables, but not in the SQL query. HOT 2
- Queries fail for column names with dashes HOT 3
- Add contributors agreement and try to apply it to post license-switch contributions
- No mac (or windows/source) packages means the installation fails. HOT 3
- Remove column name transformations when loading a dataframe into a datasource
- Aliasing a column that is used in WHERE silently produces wrong output HOT 1
- Exception if two values are compared in 'WHERE' HOT 3
- Zero length string value converts to <NA> HOT 2
- ImportError: cannot import name 'basestring' from 'pyparsing' HOT 8
- KeyError if 'ORDER BY' contains table name HOT 2
- Error if selecting column name is 'status' HOT 2
- Spontaneous error during query HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dfsql.