(
&mut self,
unbounded: bool,
or_replace: bool,
)
| 996 | } |
| 997 | |
| 998 | fn parse_create_external_table( |
| 999 | &mut self, |
| 1000 | unbounded: bool, |
| 1001 | or_replace: bool, |
| 1002 | ) -> Result<Statement, DataFusionError> { |
| 1003 | let temporary = self |
| 1004 | .parser |
| 1005 | .parse_one_of_keywords(&[Keyword::TEMP, Keyword::TEMPORARY]) |
| 1006 | .is_some(); |
| 1007 | |
| 1008 | self.parser.expect_keyword(Keyword::TABLE)?; |
| 1009 | let if_not_exists = |
| 1010 | self.parser |
| 1011 | .parse_keywords(&[Keyword::IF, Keyword::NOT, Keyword::EXISTS]); |
| 1012 | |
| 1013 | if if_not_exists && or_replace { |
| 1014 | return parser_err!("'IF NOT EXISTS' cannot coexist with 'REPLACE'"); |
| 1015 | } |
| 1016 | |
| 1017 | let table_name = self.parser.parse_object_name(true)?; |
| 1018 | let (mut columns, constraints) = self.parse_columns()?; |
| 1019 | |
| 1020 | #[derive(Default)] |
| 1021 | struct Builder { |
| 1022 | file_type: Option<String>, |
| 1023 | location: Option<String>, |
| 1024 | table_partition_cols: Option<Vec<String>>, |
| 1025 | order_exprs: Vec<LexOrdering>, |
| 1026 | options: Option<Vec<(String, Value)>>, |
| 1027 | } |
| 1028 | let mut builder = Builder::default(); |
| 1029 | |
| 1030 | loop { |
| 1031 | if let Some(keyword) = self.parser.parse_one_of_keywords(&[ |
| 1032 | Keyword::STORED, |
| 1033 | Keyword::LOCATION, |
| 1034 | Keyword::WITH, |
| 1035 | Keyword::DELIMITER, |
| 1036 | Keyword::COMPRESSION, |
| 1037 | Keyword::PARTITIONED, |
| 1038 | Keyword::OPTIONS, |
| 1039 | ]) { |
| 1040 | match keyword { |
| 1041 | Keyword::STORED => { |
| 1042 | self.parser.expect_keyword(Keyword::AS)?; |
| 1043 | ensure_not_set(&builder.file_type, "STORED AS")?; |
| 1044 | builder.file_type = Some(self.parse_file_format()?); |
| 1045 | } |
| 1046 | Keyword::LOCATION => { |
| 1047 | ensure_not_set(&builder.location, "LOCATION")?; |
| 1048 | builder.location = Some(self.parser.parse_literal_string()?); |
| 1049 | } |
| 1050 | Keyword::WITH => { |
| 1051 | if self.parser.parse_keyword(Keyword::ORDER) { |
| 1052 | builder.order_exprs.push(self.parse_order_by_exprs()?); |
| 1053 | } else { |
| 1054 | self.parser.expect_keyword(Keyword::HEADER)?; |
| 1055 | self.parser.expect_keyword(Keyword::ROW)?; |
no test coverage detected