[SPARK-15981][SQL][STREAMING] Fixed bug and added tests in DataStreamReader Python API
[SPARK-15981][SQL][STREAMING] Fixed bug and added tests in DataStreamReader Python API

## What changes were proposed in this pull request?

- Fixed bug in Python API of DataStreamReader.  Because a single path was being converted to a array before calling Java DataStreamReader method (which takes a string only), it gave the following error.
```
File "/Users/tdas/Projects/Spark/spark/python/pyspark/sql/readwriter.py", line 947, in pyspark.sql.readwriter.DataStreamReader.json
Failed example:
    json_sdf = spark.readStream.json(os.path.join(tempfile.mkdtemp(), 'data'),                 schema = sdf_schema)
Exception raised:
    Traceback (most recent call last):
      File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/doctest.py", line 1253, in __run
        compileflags, 1) in test.globs
      File "<doctest pyspark.sql.readwriter.DataStreamReader.json[0]>", line 1, in <module>
        json_sdf = spark.readStream.json(os.path.join(tempfile.mkdtemp(), 'data'),                 schema = sdf_schema)
      File "/Users/tdas/Projects/Spark/spark/python/pyspark/sql/readwriter.py", line 963, in json
        return self._df(self._jreader.json(path))
      File "/Users/tdas/Projects/Spark/spark/python/lib/py4j-0.10.1-src.zip/py4j/java_gateway.py", line 933, in __call__
        answer, self.gateway_client, self.target_id, self.name)
      File "/Users/tdas/Projects/Spark/spark/python/pyspark/sql/utils.py", line 63, in deco
        return f(*a, **kw)
      File "/Users/tdas/Projects/Spark/spark/python/lib/py4j-0.10.1-src.zip/py4j/protocol.py", line 316, in get_return_value
        format(target_id, ".", name, value))
    Py4JError: An error occurred while calling o121.json. Trace:
    py4j.Py4JException: Method json([class java.util.ArrayList]) does not exist
    	at py4j.reflection.ReflectionEngine.getMethod(ReflectionEngine.java:318)
    	at py4j.reflection.ReflectionEngine.getMethod(ReflectionEngine.java:326)
    	at py4j.Gateway.invoke(Gateway.java:272)
    	at py4j.commands.AbstractCommand.invokeMethod(AbstractCommand.java:128)
    	at py4j.commands.CallCommand.execute(CallCommand.java:79)
    	at py4j.GatewayConnection.run(GatewayConnection.java:211)
    	at java.lang.Thread.run(Thread.java:744)
```

- Reduced code duplication between DataStreamReader and DataFrameWriter
- Added missing Python doctests

## How was this patch tested?
New tests

Author: Tathagata Das <tathagata.das1565@gmail.com>

Closes #13703 from tdas/SPARK-15981.

nlalevee/spark,skonto/spark,maropu/spark,mzl9039/spark,someorz/spark,highfei2011/spark,Aegeaner/spark,xuanyuanking/spark,dongjoon-hyun/spark,ron8hu/spark,taroplus/spark,ericvandenbergfb/spark,1haodian/spark,facaiy/spark,ptkool/spark,holdenk/spark,sachintyagi22/spark,tengpeng/spark,actuaryzhang/spark,WindCanDie/spark,ptkool/spark,wangmiao1981/spark,lvdongr/spark,ConeyLiu/spark,publicRoman/spark,chuckchen/spark,Aegeaner/spark,apache/spark,rikima/spark,adrian-ionescu/apache-spark,witgo/spark,zhouyejoe/spark,minixalpha/spark,xuanyuanking/spark,sureshthalamati/spark,witgo/spark,dhruve/spark,zuotingbing/spark,byakuinss/spark,WeichenXu123/spark,joseph-torres/spark,akopich/spark,esi-mineset/spark,ibm-research-ireland/sparkoscope,WindCanDie/spark,actuaryzhang/spark,kiszk/spark,narahari92/spark,ddna1021/spark,ueshin/apache-spark,zhouyejoe/spark,goldmedal/spark,ddna1021/spark,wzhfy/spark,setjet/spark,UndeadBaneGitHub/spark,apache-spark-on-k8s/spark,panfengfeng/spark,icexelloss/spark,jrshust/spark,SnappyDataInc/spark,aray/spark,map222/spark,nchammas/spark,SnappyDataInc/spark,vinodkc/spark,rezasafi/spark,ibm-research-ireland/sparkoscope,aray/spark,kiszk/spark,michalsenkyr/spark,ron8hu/spark,MLnick/spark,jiangxb1987/spark,panfengfeng/spark,vinodkc/spark,metamx/spark,michalsenkyr/spark,milliman/spark,HyukjinKwon/spark,maropu/spark,holdenk/spark,xflin/spark,sachintyagi22/spark,icexelloss/spark,patrick-nicholson/spark,map222/spark,huang1900/spark,panfengfeng/spark,debugger87/spark,actuaryzhang/spark,sahilTakiar/spark,poffuomo/spark,MLnick/spark,ConeyLiu/spark,alunarbeach/spark,nilsgrabbert/spark,chuckchen/spark,darionyaphet/spark,rezasafi/spark,aokolnychyi/spark,jkbradley/spark,goldmedal/spark,spark-test/spark,hvanhovell/spark,apache/spark,andrewor14/spark,ajaysaini725/spark,ConeyLiu/spark,wangyum/spark,jianran/spark,jiangxb1987/spark,nilsgrabbert/spark,brad-kaiser/spark,MLnick/spark,cin/spark,esi-mineset/spark,eyalfa/spark,publicRoman/spark,1haodian/spark,goldmedal/spark,milliman/spark,facaiy/spark,lxsmnv/spark,rednaxelafx/apache-spark,jkbradley/spark,huang1900/spark,zzcclp/spark,ptkool/spark,tejasapatil/spark,JoshRosen/spark,LantaoJin/spark,esi-mineset/spark,wangyum/spark,tengpeng/spark,wangyum/spark,wangmiao1981/spark,guoxiaolongzte/spark,nchammas/spark,apache/spark,BryanCutler/spark,lvdongr/spark,zuotingbing/spark,rikima/spark,dbtsai/spark,sachintyagi22/spark,wangmiao1981/spark,ibm-research-ireland/sparkoscope,ajaysaini725/spark,alunarbeach/spark,akopich/spark,byakuinss/spark,hhbyyh/spark,jianran/spark,nilsgrabbert/spark,gengliangwang/spark,dhruve/spark,sahilTakiar/spark,metamx/spark,skonto/spark,janewangfb/spark,liyichao/spark,saltstar/spark,cin/spark,xuanyuanking/spark,setjet/spark,wzhfy/spark,janewangfb/spark,bravo-zhang/spark,huang1900/spark,JerryLead/spark,big-pegasus/spark,byakuinss/spark,apache-spark-on-k8s/spark,sureshthalamati/spark,LantaoJin/spark,kissmetrics/spark,adrian-ionescu/apache-spark,mahak/spark,rekhajoshm/spark,skonto/spark,big-pegasus/spark,ueshin/apache-spark,shuangshuangwang/spark,WeichenXu123/spark,alunarbeach/spark,taroplus/spark,wangmiao1981/spark,andrewor14/spark,sahilTakiar/spark,sureshthalamati/spark,skonto/spark,ericvandenbergfb/spark,patrick-nicholson/spark,yanboliang/spark,byakuinss/spark,chuckchen/spark,mdespriee/spark,ptkool/spark,nchammas/spark,UndeadBaneGitHub/spark,markhamstra/spark,cin/spark,dhruve/spark,jiangxb1987/spark,vinodkc/spark,caneGuy/spark,taroplus/spark,wzhfy/spark,apache/spark,bdrillard/spark,Aegeaner/spark,srowen/spark,zero323/spark,UndeadBaneGitHub/spark,WindCanDie/spark,big-pegasus/spark,shaneknapp/spark,xuanyuanking/spark,ahnqirage/spark,joseph-torres/spark,dhruve/spark,loneknightpy/spark,icexelloss/spark,nchammas/spark,xflin/spark,debugger87/spark,dongjoon-hyun/spark,janewangfb/spark,WeichenXu123/spark,setjet/spark,kevinyu98/spark,shaneknapp/spark,stanzhai/spark,minixalpha/spark,jrshust/spark,aokolnychyi/spark,kissmetrics/spark,bOOm-X/spark,ahnqirage/spark,saturday-shi/spark,dongjoon-hyun/spark,rednaxelafx/apache-spark,cloud-fan/spark,panfengfeng/spark,loneknightpy/spark,bOOm-X/spark,JerryLead/spark,jiangxb1987/spark,sureshthalamati/spark,kimoonkim/spark,witgo/spark,dongjoon-hyun/spark,jrshust/spark,loneknightpy/spark,UndeadBaneGitHub/spark,wzhfy/spark,adrian-ionescu/apache-spark,Aegeaner/spark,bravo-zhang/spark,pgandhi999/spark,spark-test/spark,big-pegasus/spark,jlopezmalla/spark,jianran/spark,Panos-Bletsos/spark-cost-model-optimizer,ioana-delaney/spark,SnappyDataInc/spark,esi-mineset/spark,vinodkc/spark,tejasapatil/spark,akopich/spark,alunarbeach/spark,milliman/spark,adrian-ionescu/apache-spark,witgo/spark,saturday-shi/spark,zero323/spark,publicRoman/spark,nlalevee/spark,liyichao/spark,holdenk/spark,saltstar/spark,minixalpha/spark,liutang123/spark,bravo-zhang/spark,michalsenkyr/spark,WeichenXu123/spark,lxsmnv/spark,caneGuy/spark,nchammas/spark,aokolnychyi/spark,nlalevee/spark,apache-spark-on-k8s/spark,1haodian/spark,actuaryzhang/spark,jiangxb1987/spark,patrick-nicholson/spark,joseph-torres/spark,zzcclp/spark,aosagie/spark,rekhajoshm/spark,apache/spark,jkbradley/spark,shuangshuangwang/spark,yanboliang/spark,dbtsai/spark,bOOm-X/spark,narahari92/spark,1haodian/spark,mike0sv/spark,spark-test/spark,pgandhi999/spark,liyichao/spark,ConeyLiu/spark,bravo-zhang/spark,WindCanDie/spark,mdespriee/spark,ericvandenbergfb/spark,nilsgrabbert/spark,tengpeng/spark,WindCanDie/spark,milliman/spark,joseph-torres/spark,WeichenXu123/spark,highfei2011/spark,SHASHANKB/spark,zuotingbing/spark,ibm-research-ireland/sparkoscope,ddna1021/spark,markhamstra/spark,someorz/spark,aosagie/spark,srowen/spark,facaiy/spark,ajaysaini725/spark,darionyaphet/spark,andrewor14/spark,ioana-delaney/spark,zzcclp/spark,witgo/spark,jianran/spark,dbtsai/spark,highfei2011/spark,tejasapatil/spark,dhruve/spark,rezasafi/spark,rednaxelafx/apache-spark,shaneknapp/spark,mahak/spark,hvanhovell/spark,lxsmnv/spark,nlalevee/spark,bOOm-X/spark,nlalevee/spark,markhamstra/spark,JoshRosen/spark,LantaoJin/spark,mike0sv/spark,andrewor14/spark,shuangshuangwang/spark,maropu/spark,nlalevee/spark,jkbradley/spark,panfengfeng/spark,aray/spark,byakuinss/spark,mzl9039/spark,shaneknapp/spark,ioana-delaney/spark,sureshthalamati/spark,zuotingbing/spark,1haodian/spark,mdespriee/spark,rekhajoshm/spark,nilsgrabbert/spark,debugger87/spark,Aegeaner/spark,guoxiaolongzte/spark,map222/spark,hhbyyh/spark,kissmetrics/spark,zhouyejoe/spark,mike0sv/spark,mzl9039/spark,sachintyagi22/spark,sureshthalamati/spark,stanzhai/spark,Panos-Bletsos/spark-cost-model-optimizer,holdenk/spark,ajaysaini725/spark,ibm-research-ireland/sparkoscope,saturday-shi/spark,xflin/spark,HyukjinKwon/spark,ron8hu/spark,nchammas/spark,rednaxelafx/apache-spark,debugger87/spark,pgandhi999/spark,HyukjinKwon/spark,1haodian/spark,andrewor14/spark,shubhamchopra/spark,andrewor14/spark,shubhamchopra/spark,guoxiaolongzte/spark,joseph-torres/spark,caneGuy/spark,Aegeaner/spark,SHASHANKB/spark,mahak/spark,alunarbeach/spark,JoshRosen/spark,WeichenXu123/spark,goldmedal/spark,joseph-torres/spark,techaddict/spark,rikima/spark,kevinyu98/spark,narahari92/spark,JerryLead/spark,Panos-Bletsos/spark-cost-model-optimizer,chuckchen/spark,UndeadBaneGitHub/spark,lvdongr/spark,jlopezmalla/spark,holdenk/spark,kiszk/spark,ioana-delaney/spark,ddna1021/spark,dbtsai/spark,liyichao/spark,liyichao/spark,narahari92/spark,LantaoJin/spark,bOOm-X/spark,aray/spark,setjet/spark,huang1900/spark,aokolnychyi/spark,techaddict/spark,zhouyejoe/spark,janewangfb/spark,janewangfb/spark,publicRoman/spark,sachintyagi22/spark,spark-test/spark,xuanyuanking/spark,narahari92/spark,tejasapatil/spark,ueshin/apache-spark,bravo-zhang/spark,milliman/spark,zero323/spark,kevinyu98/spark,shaneknapp/spark,gengliangwang/spark,michalsenkyr/spark,tengpeng/spark,rezasafi/spark,brad-kaiser/spark,patrick-nicholson/spark,icexelloss/spark,jlopezmalla/spark,facaiy/spark,aray/spark,poffuomo/spark,nilsgrabbert/spark,jlopezmalla/spark,HyukjinKwon/spark,chuckchen/spark,big-pegasus/spark,cloud-fan/spark,esi-mineset/spark,kissmetrics/spark,taroplus/spark,zzcclp/spark,poffuomo/spark,vinodkc/spark,publicRoman/spark,wzhfy/spark,cin/spark,xflin/spark,SnappyDataInc/spark,mzl9039/spark,shuangshuangwang/spark,huang1900/spark,szhem/spark,darionyaphet/spark,ConeyLiu/spark,LantaoJin/spark,mzl9039/spark,map222/spark,byakuinss/spark,zero323/spark,janewangfb/spark,ddna1021/spark,actuaryzhang/spark,jkbradley/spark,tengpeng/spark,SnappyDataInc/spark,JerryLead/spark,poffuomo/spark,akopich/spark,ioana-delaney/spark,rekhajoshm/spark,minixalpha/spark,aokolnychyi/spark,nilsgrabbert/spark,caneGuy/spark,ron8hu/spark,adrian-ionescu/apache-spark,ajaysaini725/spark,SHASHANKB/spark,rekhajoshm/spark,patrick-nicholson/spark,ueshin/apache-spark,sahilTakiar/spark,goldmedal/spark,wangyum/spark,liutang123/spark,saturday-shi/spark,szhem/spark,minixalpha/spark,kiszk/spark,zzcclp/spark,rezasafi/spark,akopich/spark,loneknightpy/spark,shubhamchopra/spark,loneknightpy/spark,SHASHANKB/spark,nlalevee/spark,dhruve/spark,sureshthalamati/spark,szhem/spark,bdrillard/spark,hhbyyh/spark,icexelloss/spark,panfengfeng/spark,maropu/spark,highfei2011/spark,map222/spark,holdenk/spark,dhruve/spark,gengliangwang/spark,markhamstra/spark,liyichao/spark,hvanhovell/spark,jrshust/spark,JerryLead/spark,cin/spark,techaddict/spark,goldmedal/spark,ahnqirage/spark,JerryLead/spark,JoshRosen/spark,poffuomo/spark,zzcclp/spark,mike0sv/spark,witgo/spark,metamx/spark,map222/spark,SHASHANKB/spark,someorz/spark,metamx/spark,stanzhai/spark,eyalfa/spark,WindCanDie/spark,stanzhai/spark,stanzhai/spark,narahari92/spark,tengpeng/spark,skonto/spark,sachintyagi22/spark,milliman/spark,wangmiao1981/spark,markhamstra/spark,lvdongr/spark,aosagie/spark,highfei2011/spark,alunarbeach/spark,rezasafi/spark,kimoonkim/spark,liutang123/spark,alunarbeach/spark,spark-test/spark,LantaoJin/spark,apache-spark-on-k8s/spark,bdrillard/spark,shubhamchopra/spark,brad-kaiser/spark,adrian-ionescu/apache-spark,UndeadBaneGitHub/spark,ibm-research-ireland/sparkoscope,MLnick/spark,JerryLead/spark,milliman/spark,szhem/spark,yanboliang/spark,srowen/spark,jiangxb1987/spark,apache/spark,cloud-fan/spark,stanzhai/spark,kissmetrics/spark,caneGuy/spark,skonto/spark,michalsenkyr/spark,jianran/spark,rekhajoshm/spark,zuotingbing/spark,SHASHANKB/spark,tejasapatil/spark,aosagie/spark,1haodian/spark,vinodkc/spark,someorz/spark,shuangshuangwang/spark,taroplus/spark,huang1900/spark,skonto/spark,BryanCutler/spark,goldmedal/spark,kimoonkim/spark,zero323/spark,brad-kaiser/spark,publicRoman/spark,shuangshuangwang/spark,WeichenXu123/spark,yanboliang/spark,jlopezmalla/spark,highfei2011/spark,techaddict/spark,dbtsai/spark,techaddict/spark,SHASHANKB/spark,kevinyu98/spark,jkbradley/spark,Panos-Bletsos/spark-cost-model-optimizer,brad-kaiser/spark,debugger87/spark,loneknightpy/spark,setjet/spark,jrshust/spark,wangmiao1981/spark,sachintyagi22/spark,ptkool/spark,gengliangwang/spark,loneknightpy/spark,liutang123/spark,jrshust/spark,michalsenkyr/spark,mzl9039/spark,mdespriee/spark,Panos-Bletsos/spark-cost-model-optimizer,yanboliang/spark,kevinyu98/spark,aosagie/spark,liutang123/spark,wzhfy/spark,ptkool/spark,yanboliang/spark,ahnqirage/spark,SnappyDataInc/spark,ahnqirage/spark,rekhajoshm/spark,BryanCutler/spark,someorz/spark,eyalfa/spark,akopich/spark,ueshin/apache-spark,ddna1021/spark,zhouyejoe/spark,lxsmnv/spark,kiszk/spark,techaddict/spark,hhbyyh/spark,xuanyuanking/spark,debugger87/spark,Panos-Bletsos/spark-cost-model-optimizer,aosagie/spark,rikima/spark,zuotingbing/spark,mike0sv/spark,saltstar/spark,wangyum/spark,guoxiaolongzte/spark,srowen/spark,xflin/spark,UndeadBaneGitHub/spark,BryanCutler/spark,ericvandenbergfb/spark,saturday-shi/spark,chuckchen/spark,saltstar/spark,lxsmnv/spark,zuotingbing/spark,jkbradley/spark,wangmiao1981/spark,bdrillard/spark,saturday-shi/spark,eyalfa/spark,HyukjinKwon/spark,metamx/spark,mahak/spark,facaiy/spark,lvdongr/spark,bOOm-X/spark,ajaysaini725/spark,eyalfa/spark,kimoonkim/spark,MLnick/spark,andrewor14/spark,rednaxelafx/apache-spark,mike0sv/spark,cin/spark,lvdongr/spark,hvanhovell/spark,zero323/spark,eyalfa/spark,ron8hu/spark,mdespriee/spark,vinodkc/spark,pgandhi999/spark,tengpeng/spark,nchammas/spark,apache/spark,bravo-zhang/spark,dbtsai/spark,LantaoJin/spark,byakuinss/spark,wangyum/spark,hvanhovell/spark,bdrillard/spark,srowen/spark,mdespriee/spark,szhem/spark,ueshin/apache-spark,gengliangwang/spark,MLnick/spark,ahnqirage/spark,ron8hu/spark,shaneknapp/spark,szhem/spark,cloud-fan/spark,adrian-ionescu/apache-spark,kevinyu98/spark,WindCanDie/spark,brad-kaiser/spark,markhamstra/spark,patrick-nicholson/spark,darionyaphet/spark,kiszk/spark,setjet/spark,facaiy/spark,HyukjinKwon/spark,aray/spark,xflin/spark,patrick-nicholson/spark,cloud-fan/spark,kissmetrics/spark,ericvandenbergfb/spark,xuanyuanking/spark,dongjoon-hyun/spark,narahari92/spark,ddna1021/spark,ueshin/apache-spark,markhamstra/spark,caneGuy/spark,stanzhai/spark,jiangxb1987/spark,saturday-shi/spark,apache-spark-on-k8s/spark,kimoonkim/spark,kimoonkim/spark,bdrillard/spark,ptkool/spark,publicRoman/spark,darionyaphet/spark,gengliangwang/spark,rezasafi/spark,apache-spark-on-k8s/spark,kevinyu98/spark,taroplus/spark,hhbyyh/spark,metamx/spark,liutang123/spark,HyukjinKwon/spark,ConeyLiu/spark,eyalfa/spark,yanboliang/spark,hhbyyh/spark,saltstar/spark,lxsmnv/spark,szhem/spark,jrshust/spark,holdenk/spark,janewangfb/spark,dongjoon-hyun/spark,BryanCutler/spark,icexelloss/spark,highfei2011/spark,cin/spark,darionyaphet/spark,maropu/spark,big-pegasus/spark,guoxiaolongzte/spark,BryanCutler/spark,poffuomo/spark,shaneknapp/spark,brad-kaiser/spark,esi-mineset/spark,ajaysaini725/spark,dongjoon-hyun/spark,guoxiaolongzte/spark,aray/spark,ioana-delaney/spark,sahilTakiar/spark,zero323/spark,cloud-fan/spark,shuangshuangwang/spark,jianran/spark,actuaryzhang/spark,guoxiaolongzte/spark,akopich/spark,rikima/spark,liyichao/spark,jianran/spark,mahak/spark,rednaxelafx/apache-spark,lxsmnv/spark,aokolnychyi/spark,hvanhovell/spark,liutang123/spark,rednaxelafx/apache-spark,rikima/spark,pgandhi999/spark,aokolnychyi/spark,bravo-zhang/spark,maropu/spark,pgandhi999/spark,big-pegasus/spark,spark-test/spark,zzcclp/spark,JoshRosen/spark,SnappyDataInc/spark,aosagie/spark,someorz/spark,apache-spark-on-k8s/spark,ericvandenbergfb/spark,maropu/spark,panfengfeng/spark,cloud-fan/spark,sahilTakiar/spark,wangyum/spark,BryanCutler/spark,actuaryzhang/spark,shubhamchopra/spark,wzhfy/spark,srowen/spark,mzl9039/spark,bdrillard/spark,mahak/spark,huang1900/spark,gengliangwang/spark,shubhamchopra/spark,hvanhovell/spark,saltstar/spark,xflin/spark,spark-test/spark,matthewfranglen/spark,lvdongr/spark,minixalpha/spark,jlopezmalla/spark,taroplus/spark,tejasapatil/spark,zhouyejoe/spark,darionyaphet/spark,ahnqirage/spark,ConeyLiu/spark,JoshRosen/spark,joseph-torres/spark,ibm-research-ireland/sparkoscope,ron8hu/spark,JoshRosen/spark,minixalpha/spark,bOOm-X/spark,srowen/spark,MLnick/spark,hhbyyh/spark,shubhamchopra/spark,jlopezmalla/spark,dbtsai/spark,kiszk/spark,chuckchen/spark,ericvandenbergfb/spark,sahilTakiar/spark,techaddict/spark,Aegeaner/spark,facaiy/spark,esi-mineset/spark,metamx/spark,tejasapatil/spark,mdespriee/spark,kimoonkim/spark,setjet/spark,michalsenkyr/spark,Panos-Bletsos/spark-cost-model-optimizer,poffuomo/spark,kissmetrics/spark,ioana-delaney/spark,mahak/spark,pgandhi999/spark,mike0sv/spark,icexelloss/spark,debugger87/spark,map222/spark,zhouyejoe/spark,rikima/spark,someorz/spark,saltstar/spark,witgo/spark,caneGuy/spark