[SPARK-31578][R] Vectorize schema validation for arrow in types.R
[SPARK-31578][R] Vectorize schema validation for arrow in types.R

### What changes were proposed in this pull request?

Repeated `sapply` avoided in internal `checkSchemaInArrow`

### Why are the changes needed?

Current implementation is doubly inefficient:

 1. Repeatedly doing the same (95%) `sapply` loop
 2. Doing scalar `==` on a vector (`==` should be done over the whole vector for efficiency)

### Does this PR introduce any user-facing change?

No

### How was this patch tested?

By my trusty friend the CI bots

Closes #28372 from MichaelChirico/vectorize-types.

Authored-by: Michael Chirico <931e2101ff62f9f4398409c662bda9c8a83df286@grabtaxi.com>
Signed-off-by: HyukjinKwon <2680965ad5aae29275c8fb10150cb10f5554e78b@apache.org>

xuanyuanking/spark,ptkool/spark,chuckchen/spark,zuotingbing/spark,cloud-fan/spark,srowen/spark,kevinyu98/spark,cloud-fan/spark,wangmiao1981/spark,wangyum/spark,cloud-fan/spark,zzcclp/spark,zero323/spark,BryanCutler/spark,holdenk/spark,zuotingbing/spark,xuanyuanking/spark,kevinyu98/spark,shaneknapp/spark,srowen/spark,vinodkc/spark,shaneknapp/spark,maropu/spark,nchammas/spark,apache/spark,srowen/spark,shuangshuangwang/spark,zuotingbing/spark,dongjoon-hyun/spark,BryanCutler/spark,xuanyuanking/spark,shaneknapp/spark,holdenk/spark,WeichenXu123/spark,gengliangwang/spark,ptkool/spark,hvanhovell/spark,apache/spark,zzcclp/spark,dbtsai/spark,srowen/spark,chuckchen/spark,kevinyu98/spark,wangmiao1981/spark,HyukjinKwon/spark,dbtsai/spark,ConeyLiu/spark,srowen/spark,witgo/spark,vinodkc/spark,kevinyu98/spark,zero323/spark,zero323/spark,taroplus/spark,vinodkc/spark,hvanhovell/spark,wzhfy/spark,rednaxelafx/apache-spark,JoshRosen/spark,spark-test/spark,ConeyLiu/spark,hvanhovell/spark,hvanhovell/spark,shaneknapp/spark,shuangshuangwang/spark,JoshRosen/spark,mahak/spark,ptkool/spark,xuanyuanking/spark,taroplus/spark,maropu/spark,dbtsai/spark,hvanhovell/spark,WeichenXu123/spark,wangyum/spark,cloud-fan/spark,chuckchen/spark,shaneknapp/spark,wzhfy/spark,vinodkc/spark,zero323/spark,wangyum/spark,gengliangwang/spark,xuanyuanking/spark,shaneknapp/spark,rednaxelafx/apache-spark,milliman/spark,nchammas/spark,taroplus/spark,wangmiao1981/spark,apache/spark,kevinyu98/spark,nchammas/spark,dbtsai/spark,ptkool/spark,maropu/spark,apache/spark,taroplus/spark,gengliangwang/spark,holdenk/spark,jiangxb1987/spark,maropu/spark,chuckchen/spark,shuangshuangwang/spark,maropu/spark,mahak/spark,nchammas/spark,ueshin/apache-spark,jiangxb1987/spark,milliman/spark,kevinyu98/spark,HyukjinKwon/spark,zzcclp/spark,WeichenXu123/spark,holdenk/spark,zuotingbing/spark,JoshRosen/spark,rednaxelafx/apache-spark,ConeyLiu/spark,shuangshuangwang/spark,dongjoon-hyun/spark,ueshin/apache-spark,witgo/spark,apache/spark,cloud-fan/spark,wangmiao1981/spark,chuckchen/spark,ptkool/spark,ueshin/apache-spark,zuotingbing/spark,dongjoon-hyun/spark,srowen/spark,shaneknapp/spark,taroplus/spark,jiangxb1987/spark,milliman/spark,nchammas/spark,ueshin/apache-spark,holdenk/spark,jiangxb1987/spark,vinodkc/spark,HyukjinKwon/spark,cloud-fan/spark,mahak/spark,shuangshuangwang/spark,xuanyuanking/spark,ueshin/apache-spark,gengliangwang/spark,ueshin/apache-spark,ptkool/spark,chuckchen/spark,WeichenXu123/spark,dbtsai/spark,spark-test/spark,zuotingbing/spark,JoshRosen/spark,BryanCutler/spark,zzcclp/spark,shuangshuangwang/spark,zzcclp/spark,wangyum/spark,srowen/spark,mahak/spark,apache/spark,wzhfy/spark,wzhfy/spark,kevinyu98/spark,HyukjinKwon/spark,BryanCutler/spark,taroplus/spark,spark-test/spark,wangmiao1981/spark,milliman/spark,WeichenXu123/spark,rednaxelafx/apache-spark,jiangxb1987/spark,rednaxelafx/apache-spark,BryanCutler/spark,zuotingbing/spark,gengliangwang/spark,HyukjinKwon/spark,gengliangwang/spark,witgo/spark,JoshRosen/spark,WeichenXu123/spark,spark-test/spark,BryanCutler/spark,xuanyuanking/spark,spark-test/spark,ueshin/apache-spark,maropu/spark,zero323/spark,BryanCutler/spark,zero323/spark,wzhfy/spark,ConeyLiu/spark,dongjoon-hyun/spark,nchammas/spark,wangyum/spark,maropu/spark,wzhfy/spark,HyukjinKwon/spark,JoshRosen/spark,mahak/spark,dbtsai/spark,holdenk/spark,jiangxb1987/spark,wangyum/spark,ConeyLiu/spark,apache/spark,spark-test/spark,wzhfy/spark,dongjoon-hyun/spark,zero323/spark,nchammas/spark,chuckchen/spark,vinodkc/spark,dongjoon-hyun/spark,zzcclp/spark,witgo/spark,wangmiao1981/spark,wangmiao1981/spark,JoshRosen/spark,jiangxb1987/spark,WeichenXu123/spark,hvanhovell/spark,witgo/spark,HyukjinKwon/spark,cloud-fan/spark,spark-test/spark,milliman/spark,ConeyLiu/spark,mahak/spark,holdenk/spark,taroplus/spark,gengliangwang/spark,shuangshuangwang/spark,hvanhovell/spark,wangyum/spark,dbtsai/spark,vinodkc/spark,milliman/spark,ptkool/spark,dongjoon-hyun/spark,milliman/spark,witgo/spark,rednaxelafx/apache-spark,witgo/spark,rednaxelafx/apache-spark,zzcclp/spark,ConeyLiu/spark,mahak/spark