from couchbase.auth import PasswordAuthenticator
            from couchbase.cluster import Cluster
            from couchbase.options import ClusterOptions
        except ImportError as e:
            raise ImportError(
                "Could not import couchbase package."
                "Please install couchbase SDK with `pip install couchbase`."
            ) from e
        if not connection_string:
            raise ValueError("connection_string must be provided.")
        if not db_username:
            raise ValueError("db_username must be provided.")
        if not db_password:
            raise ValueError("db_password must be provided.")
        auth = PasswordAuthenticator(
            db_username,
            db_password,
        )
        self.cluster: Cluster = Cluster(connection_string, ClusterOptions(auth))
        self.query = query
        self.page_content_fields = page_content_fields
        self.metadata_fields = metadata_fields
[docs]    def load(self) -> List[Document]:
        """Load Couchbase data into Document objects."""
        return list(self.lazy_load())
[docs]    def lazy_load(self) -> Iterator[Document]:
        """Load Couchbase data into Document objects lazily."""
        from datetime import timedelta
        # Ensure connection to Couchbase cluster
        self.cluster.wait_until_ready(timedelta(seconds=5))
        # Run SQL++ Query
        result = self.cluster.query(self.query)
        for row in result:
            metadata_fields = self.metadata_fields
            page_content_fields = self.page_content_fields
            if not page_content_fields:
                page_content_fields = list(row.keys())
            if not metadata_fields:
                metadata_fields = []
            metadata = {field: row[field] for field in metadata_fields}
            document = "\n".join(
                f"{k}: {v}" for k, v in row.items() if k in page_content_fields
            )