Skip to content

Commit

Permalink
auto generate doc
Browse files Browse the repository at this point in the history
  • Loading branch information
yaooqinn committed Feb 22, 2021
1 parent 3eaec5f commit f2d4701
Show file tree
Hide file tree
Showing 32 changed files with 1,082 additions and 106 deletions.
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,8 @@ warehouse/
spark-warehouse/

.idea/vcs.xml
.bsp
.bsp

docs/_build
docs/_static
docs/_templates
36 changes: 36 additions & 0 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

version: 2

# Build documentation in the docs/ directory with Sphinx
sphinx:
builder: html
configuration: docs/conf.py

# Build documentation with MkDocs
#mkdocs:
# configuration: mkdocs.yml

# Optionally build your docs in additional formats such as PDF
formats:
- pdf
- epub

# Optionally set the version of Python and requirements required to build your docs
python:
version: 3.7
install:
- requirements: docs/requirements.txt
88 changes: 30 additions & 58 deletions README.md → README.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# itachi
itachi
======

itachi brings useful functions from modern database management systems to Apache Spark :)

Expand All @@ -8,15 +9,16 @@ The functions are implemented as native Spark functions, so they're performant.

In general, only those functions that difficult for the Apache Spark Community to maintain in the master branch will be added to this library.

## Installation
Installation
------------

Fetch the JAR file from Maven.

```scala
libraryDependencies += "com.github.yaooqinn" %% "itachi" % "0.1.0"
```

Here's [the Maven link](https://repo1.maven.org/maven2/com/github/yaooqinn/itachi_2.12/) where the JAR files are stored.
Here's `the Maven link <https://repo1.maven.org/maven2/com/github/yaooqinn/itachi_2.12/>`_ where the JAR files are stored.

itachi requires Spark 3+.

Expand All @@ -25,71 +27,41 @@ Config your spark applications with `spark.sql.extensions`, e.g. `spark.sql.exte
- org.apache.spark.sql.extra.PostgreSQLExtensions
- org.apache.spark.sql.extra.TeradataExtensions

## Simple example
Simple example
--------------

Suppose you have the following data table and would like to join the two arrays, with the familiar [array_cat](https://w3resource.com/PostgreSQL/postgresql_array_cat-function.php) function from Postgres.
Suppose you have the following data table and would like to join the two arrays, with the familiar `array_cat <https://w3resource.com/PostgreSQL/postgresql_array_cat-function.php>`_ function from Postgres.::

```
+------+------+
| arr1| arr2|
+------+------+
|[1, 2]| []|
|[1, 2]|[1, 3]|
+------+------+
```
+------+------+
| arr1| arr2|
+------+------+
|[1, 2]| []|
|[1, 2]|[1, 3]|
+------+------+

Concatenate the two arrays:
Concatenate the two arrays:::

```scala
spark
.sql("select array_cat(arr1, arr2) as both_arrays from some_data")
.show()
```
spark
.sql("select array_cat(arr1, arr2) as both_arrays from some_data")
.show()

```
+------------+
| both_arrays|
+------------+
| [1, 2]|
|[1, 2, 1, 3]|
+------------+
```
+------------+
| both_arrays|
+------------+
| [1, 2]|
|[1, 2, 1, 3]|
+------------+

itachi lets you write Spark SQL code that looks just like Postgres SQL!

## Spark SQL Compliance
Spark SQL Compliance
--------------------

This is a Spark SQL extension supplying add-on or aliased functions to the Apache Spark SQL builtin standard functions.

The functions in this library take precedence over the native Spark functions in the even of a name conflict.

## Functions from Teradata/Presto

- char2HexInt
- cosine_similarity
- editdistance
- from_base
- index
- infinity
- is_finite
- is_infinite
- NaN
- try
- to_base


## Functions from PostgreSQL

- age
- array_append
- array_cat
- array_length
- justifyDays
- justifyHours
- justifyInterval
- scale
- split_part
- string_to_array
- unnest

** More popular modern dbms system function can be added with your help **
Contributing
------------

**More popular modern dbms system function can be added with your help**
20 changes: 20 additions & 0 deletions docs/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Minimal makefile for Sphinx documentation
#

# You can set these variables from the command line, and also
# from the environment for the first two.
SPHINXOPTS ?=
SPHINXBUILD ?= sphinx-build
SOURCEDIR = .
BUILDDIR = _build

# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

.PHONY: help Makefile

# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
103 changes: 103 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
# Configuration file for the Sphinx documentation builder.
#
# This file only contains a selection of the most common options. For a full
# list see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html

# -- Path setup --------------------------------------------------------------

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#

import os
import sys
import shlex

sys.path.insert(0, os.path.abspath('.'))

import sphinx_rtd_theme
html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]

import sphinx_markdown_tables
import recommonmark
from recommonmark.transform import AutoStructify
from recommonmark.parser import CommonMarkParser
# source_parsers = {
# '.md': CommonMarkParser,
# }

source_suffix = ['.rst', '.md']


# -- Project information -----------------------------------------------------

project = 'itachi'

copyright = '''
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
'''

author = 'Kent Yao'

# The full version, including alpha/beta/rc tags
release = '0.1.0'


# -- General configuration ---------------------------------------------------

# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
'sphinx.ext.autodoc',
'sphinx.ext.napoleon',
'sphinx.ext.mathjax',
'recommonmark',
'sphinx_markdown_tables',
'notfound.extension',
]

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']


# -- Options for HTML output -------------------------------------------------

# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = 'sphinx_rtd_theme'
pygments_style = 'sphinx'

# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
htmlhelp_basename = 'Recommonmarkdoc'

github_doc_root = 'https://github.com/yaooqinn/itachi/tree/master/docs/'
def setup(app):
app.add_config_value('recommonmark_config', {
'url_resolver': lambda url: github_doc_root + url,
'auto_toc_tree_section': 'Contents',
'enable_eval_rst': True,
}, True)
app.add_transform(AutoStructify)
18 changes: 18 additions & 0 deletions docs/functions/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
Itachi Function List
====================


.. toctree::
:caption: Postgres
:maxdepth: 2
:glob:

postgres


.. toctree::
:caption: Presto/Teradata
:maxdepth: 2
:glob:

presto
Loading

0 comments on commit f2d4701

Please sign in to comment.