[SPARK-6812] [SPARKR] filter() on DataFrame does not work as expected.
[SPARK-6812] [SPARKR] filter() on DataFrame does not work as expected.

According to the R manual: https://stat.ethz.ch/R-manual/R-devel/library/base/html/Startup.html,
" if a function .First is found on the search path, it is executed as .First(). Finally, function .First.sys() in the base package is run. This calls require to attach the default packages specified by options("defaultPackages")."
In .First() in profile/shell.R, we load SparkR package. This means SparkR package is loaded before default packages. If there are same names in default packages, they will overwrite those in SparkR. This is why filter() in SparkR is masked by filter() in stats, which is usually in the default package list.
We need to make sure SparkR is loaded after default packages. The solution is to append SparkR to default packages, instead of loading SparkR in .First().

BTW, I'd like to discuss our policy on how to solve name conflict. Previously, we rename API names from Scala API if there is name conflict with base or other commonly-used packages. However, from long term perspective, this is not good for API stability, because we can't predict name conflicts, for example, if in the future a name added in base package conflicts with an API in SparkR? So the better policy is to keep API name same as Scala's without worrying about name conflicts. When users use SparkR, they should load SparkR as last package, so that all API names are effective. Use can explicitly use :: to refer to hidden names from other packages. If we agree on this, I can submit a JIRA issue to change back some rename API methods, for example, DataFrame.sortDF().

Author: Sun Rui <rui.sun@intel.com>

Closes #5938 from sun-rui/SPARK-6812 and squashes the following commits:

b569145 [Sun Rui] [SPARK-6812][SparkR] filter() on DataFrame does not work as expected.

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