[SPARK-15803] [PYSPARK] Support with statement syntax for SparkSession
[SPARK-15803] [PYSPARK] Support with statement syntax for SparkSession

## What changes were proposed in this pull request?

Support with statement syntax for SparkSession in pyspark

## How was this patch tested?

Manually verify it. Although I can add unit test for it, it would affect other unit test because the SparkContext is stopped after the with statement.

Author: Jeff Zhang <zjffdu@apache.org>

Closes #13541 from zjffdu/SPARK-15803.

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