Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 58842200CCC for ; Fri, 21 Jul 2017 11:21:05 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 5727C16CE8C; Fri, 21 Jul 2017 09:21:05 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 9AA8716CE8A for ; Fri, 21 Jul 2017 11:21:04 +0200 (CEST) Received: (qmail 74119 invoked by uid 500); 21 Jul 2017 09:21:03 -0000 Mailing-List: contact issues-help@spark.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Delivered-To: mailing list issues@spark.apache.org Received: (qmail 74108 invoked by uid 99); 21 Jul 2017 09:21:03 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd2-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 21 Jul 2017 09:21:03 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd2-us-west.apache.org (ASF Mail Server at spamd2-us-west.apache.org) with ESMTP id 410691A04E6 for ; Fri, 21 Jul 2017 09:21:02 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -99.992 X-Spam-Level: X-Spam-Status: No, score=-99.992 tagged_above=-999 required=6.31 tests=[RP_MATCHES_RCVD=-0.001, SPF_PASS=-0.001, T_FILL_THIS_FORM_SHORT=0.01, USER_IN_WHITELIST=-100] autolearn=disabled Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd2-us-west.apache.org [10.40.0.9]) (amavisd-new, port 10024) with ESMTP id LkQ8H8WNm4kH for ; Fri, 21 Jul 2017 09:21:02 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTP id C56B65FD6F for ; Fri, 21 Jul 2017 09:21:01 +0000 (UTC) Received: from jira-lw-us.apache.org (unknown [207.244.88.139]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id E0E6CE0DCA for ; Fri, 21 Jul 2017 09:21:00 +0000 (UTC) Received: from jira-lw-us.apache.org (localhost [127.0.0.1]) by jira-lw-us.apache.org (ASF Mail Server at jira-lw-us.apache.org) with ESMTP id 2AB8D21EE7 for ; Fri, 21 Jul 2017 09:21:00 +0000 (UTC) Date: Fri, 21 Jul 2017 09:21:00 +0000 (UTC) From: "Apache Spark (JIRA)" To: issues@spark.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Assigned] (SPARK-21485) API Documentation for Spark SQL functions MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Fri, 21 Jul 2017 09:21:05 -0000 [ https://issues.apache.org/jira/browse/SPARK-21485?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Apache Spark reassigned SPARK-21485: ------------------------------------ Assignee: Apache Spark > API Documentation for Spark SQL functions > ----------------------------------------- > > Key: SPARK-21485 > URL: https://issues.apache.org/jira/browse/SPARK-21485 > Project: Spark > Issue Type: Documentation > Components: Documentation, SQL > Affects Versions: 2.3.0 > Reporter: Hyukjin Kwon > Assignee: Apache Spark > > It looks we can generate the documentation from {{ExpressionDescription}} and {{ExpressionInfo}} for Spark's SQL function documentation. > I had some time to play with this so I just made a rough version - https://spark-test.github.io/sparksqldoc/ > Codes I used are as below : > In {{pyspark}} shell: > {code} > from collections import namedtuple > ExpressionInfo = namedtuple("ExpressionInfo", "className usage name extended") > jinfos = spark.sparkContext._jvm.org.apache.spark.sql.api.python.PythonSQLUtils.listBuiltinFunctions() > infos = [] > for jinfo in jinfos: > name = jinfo.getName() > usage = jinfo.getUsage() > usage = usage.replace("_FUNC_", name) if usage is not None else usage > extended = jinfo.getExtended() > extended = extended.replace("_FUNC_", name) if extended is not None else extended > infos.append(ExpressionInfo( > className=jinfo.getClassName(), > usage=usage, > name=name, > extended=extended)) > with open("index.md", 'w') as mdfile: > strip = lambda s: "\n".join(map(lambda u: u.strip(), s.split("\n"))) > for info in sorted(infos, key=lambda i: i.name): > mdfile.write("### %s\n\n" % info.name) > if info.usage is not None: > mdfile.write("%s\n\n" % strip(info.usage)) > if info.extended is not None: > mdfile.write("```%s```\n\n" % strip(info.extended)) > {code} > This change had to be made first before running the codes above: > {code:none} > +++ b/sql/core/src/main/scala/org/apache/spark/sql/api/python/PythonSQLUtils.scala > @@ -17,9 +17,15 @@ > package org.apache.spark.sql.api.python > +import org.apache.spark.sql.catalyst.analysis.FunctionRegistry > +import org.apache.spark.sql.catalyst.expressions.ExpressionInfo > import org.apache.spark.sql.catalyst.parser.CatalystSqlParser > import org.apache.spark.sql.types.DataType > private[sql] object PythonSQLUtils { > def parseDataType(typeText: String): DataType = CatalystSqlParser.parseDataType(typeText) > + > + def listBuiltinFunctions(): Array[ExpressionInfo] = { > + FunctionRegistry.functionSet.flatMap(f => FunctionRegistry.builtin.lookupFunction(f)).toArray > + } > } > {code} > And then, I ran this: > {code} > mkdir docs > echo "site_name: Spark SQL 2.3.0" >> mkdocs.yml > echo "theme: readthedocs" >> mkdocs.yml > mv index.md docs/index.md > mkdocs serve > {code} -- This message was sent by Atlassian JIRA (v6.4.14#64029) --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscribe@spark.apache.org For additional commands, e-mail: issues-help@spark.apache.org